Documentation
¶
Index ¶
- Variables
- type Config
- type Storage
- func (s *Storage) Close()
- func (s *Storage) Conn() *gocql.Session
- func (s *Storage) Delete(key string) error
- func (s *Storage) DeleteWithContext(ctx context.Context, key string) error
- func (s *Storage) Get(key string) ([]byte, error)
- func (s *Storage) GetWithContext(ctx context.Context, key string) ([]byte, error)
- func (s *Storage) Reset() error
- func (s *Storage) ResetWithContext(ctx context.Context) error
- func (s *Storage) Set(key string, value []byte, exp time.Duration) error
- func (s *Storage) SetWithContext(ctx context.Context, key string, value []byte, exp time.Duration) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound is returned when the key does not exist ErrNotFound = fmt.Errorf("key not found") // ErrKeyExpired is returned when the key has expired ErrKeyExpired = fmt.Errorf("key expired") )
View Source
var ConfigDefault = Config{ Hosts: []string{"localhost:9042"}, Keyspace: "gofiber", Table: "kv_store", Consistency: gocql.Quorum, Reset: false, Expiration: 10 * time.Minute, MaxRetries: 3, ConnectTimeout: 5 * time.Second, SslOpts: nil, PoolConfig: &gocql.PoolConfig{ HostSelectionPolicy: gocql.TokenAwareHostPolicy(gocql.RoundRobinHostPolicy()), }, }
ConfigDefault is the default config
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Optional. Default is localhost
// Hosts is a list of Cassandra nodes to connect to.
Hosts []string
// Optional. Default is gofiber
// Keyspace is the name of the Cassandra keyspace to use.
Keyspace string
// Optional. Default is kv_store
// Table is the name of the Cassandra table to use.
Table string
// Optional. Default is Quorum
// Consistency is the Cassandra consistency level.
Consistency gocql.Consistency
// Optional. PoolConfig.HostSelectionPolicy = gocql.TokenAwareHostPolicy(gocql.RoundRobinHostPolicy())
// PoolConfig is the Cassandra connection pool configuration.
PoolConfig *gocql.PoolConfig
// Optional. Default is false
// SslOpts is the SSL options for the Cassandra cluster.
SslOpts *gocql.SslOptions
// Optional. Default is 10 minutes
// Expiration is the time after which an entry is considered expired.
Expiration time.Duration
// Optional. Default is false
// Reset is a flag to reset the database.
Reset bool
// Optional. Default is 3
// MaxRetries is the maximum number of retries for a query.
MaxRetries int
// Optional. Default is 5 seconds
// ConnectTimeout is the timeout for connecting to the Cassandra cluster.
ConnectTimeout time.Duration
}
Config defines the configuration options for the Cassandra storage
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage represents a Cassandra storage implementation
func (*Storage) Close ¶
func (s *Storage) Close()
Close closes the storage connection. This method is not thread-safe and should not be called concurrently with other methods.
func (*Storage) DeleteWithContext ¶ added in v0.2.0
DeleteWithContext removes a key from storage with context support.
func (*Storage) GetWithContext ¶ added in v0.2.0
GetWithContext retrieves a value by key with context support.
func (*Storage) ResetWithContext ¶ added in v0.2.0
ResetWithContext clears all keys from storage with context support.
Click to show internal directories.
Click to hide internal directories.