couchbase

package module
v2.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 3 Imported by: 0

README


id: couchbase title: Couchbase

Release Discord Test

A Couchbase storage driver using couchbase/gocb.

Table of Contents

Signatures

func New(config ...Config) Storage
func (s *Storage) Get(key string) ([]byte, error)
func (s *Storage) GetWithContext(ctx context.Context, key string) ([]byte, error)
func (s *Storage) Set(key string, val []byte, exp time.Duration) error
func (s *Storage) SetWithContext(ctx context.Context, key string, val []byte, exp time.Duration) error
func (s *Storage) Delete(key string) error
func (s *Storage) DeleteWithContext(ctx context.Context, key string) error
func (s *Storage) Reset() error
func (s *Storage) ResetWithContext(ctx context.Context) error
func (s *Storage) Close() error
func (s *Storage) Conn() *gocb.Cluster

Installation

Couchbase is tested on the 2 last Go versions with support for modules. So make sure to initialize one first if you didn't do that yet:

go mod init github.com/<user>/<repo>

And then install the Couchbase implementation:

go get github.com/gofiber/storage/couchbase/v2

Examples

Import the storage package.

import "github.com/gofiber/storage/couchbase/v2"

You can use the following possibilities to create a storage:

// Initialize default config
store := couchbase.New()

// Initialize Couchbase storage with custom config
store := couchbase.New(couchbase.Config{
	Host:      "127.0.0.1:8091",
	Username:  "",
	Password:  "",
	Bucket:  0,
	ConnectionTimeout: 3* time.Second,
	KVTimeout: 1* time.Second,
})

Config

type Config struct {
    // The application username to Connect to the Couchbase cluster
    Username string
    // The application password to Connect to the Couchbase cluster
    Password string
    // The connection string for the Couchbase cluster
    Host string
    // The name of the bucket to Connect to
    Bucket string
    // The timeout for connecting to the Couchbase cluster
    ConnectionTimeout time.Duration
    // The timeout for performing operations on the Couchbase cluster
    KVTimeout time.Duration
}

Default Config

// ConfigDefault is the default config
var ConfigDefault = Config{
    Host:              "127.0.0.1:8091",
    Username:          "admin",
    Password:          "123456",
    Bucket:            "fiber_storage",
    ConnectionTimeout: 3 * time.Second,
    KVTimeout:         1 * time.Second,
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigDefault = Config{
	Host:              "127.0.0.1:8091",
	Username:          "admin",
	Password:          "123456",
	Bucket:            "fiber_storage",
	ConnectionTimeout: 3 * time.Second,
	KVTimeout:         1 * time.Second,
}

ConfigDefault is the default config

Functions

This section is empty.

Types

type Config

type Config struct {
	// The application username to Connect to the Couchbase cluster
	Username string
	// The application password to Connect to the Couchbase cluster
	Password string
	// The connection string for the Couchbase cluster
	Host string
	// The name of the bucket to Connect to
	Bucket string
	// The timeout for connecting to the Couchbase cluster
	ConnectionTimeout time.Duration
	// The timeout for performing operations on the Couchbase cluster
	KVTimeout time.Duration
}

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

func New

func New(config ...Config) *Storage

func (*Storage) Close

func (s *Storage) Close() error

func (*Storage) Conn

func (s *Storage) Conn() *gocb.Cluster

func (*Storage) Delete

func (s *Storage) Delete(key string) error

func (*Storage) DeleteWithContext added in v2.2.0

func (s *Storage) DeleteWithContext(ctx context.Context, key string) error

func (*Storage) Get

func (s *Storage) Get(key string) ([]byte, error)

func (*Storage) GetWithContext added in v2.2.0

func (s *Storage) GetWithContext(ctx context.Context, key string) ([]byte, error)

func (*Storage) Reset

func (s *Storage) Reset() error

func (*Storage) ResetWithContext added in v2.2.0

func (s *Storage) ResetWithContext(ctx context.Context) error

func (*Storage) Set

func (s *Storage) Set(key string, val []byte, exp time.Duration) error

func (*Storage) SetWithContext added in v2.2.0

func (s *Storage) SetWithContext(ctx context.Context, key string, val []byte, exp time.Duration) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL