Documentation
¶
Index ¶
- Constants
- Variables
- func SetupLocalPDInstance(ctx context.Context) (string, testcontainers.Container, func(), error)
- func SetupLocalTiKVInstance(ctx context.Context) (string, testcontainers.Container, func(), error)
- func SetupLocalValKeyInstance(ctx context.Context) (string, testcontainers.Container, func(), error)
- type Config
- type KVExecutor
- type KVManager
- type Key
- type KeyValue
- type SQLiteManager
- type VKExecutor
- func (r *VKExecutor) Delete(ctx context.Context, key Key) error
- func (r *VKExecutor) Exists(ctx context.Context, key Key) (bool, error)
- func (r *VKExecutor) Get(ctx context.Context, key Key) (json.RawMessage, error)
- func (r *VKExecutor) Keys(ctx context.Context, pattern string) ([]Key, error)
- func (r *VKExecutor) ListLength(ctx context.Context, key Key) (int64, error)
- func (r *VKExecutor) ListPush(ctx context.Context, key Key, value json.RawMessage) error
- func (r *VKExecutor) ListRPop(ctx context.Context, key Key) (json.RawMessage, error)
- func (r *VKExecutor) ListRange(ctx context.Context, key Key, start, stop int64) ([]json.RawMessage, error)
- func (r *VKExecutor) ListTrim(ctx context.Context, key Key, start, stop int64) error
- func (r *VKExecutor) Set(ctx context.Context, key Key, value json.RawMessage) error
- func (r *VKExecutor) SetAdd(ctx context.Context, key Key, member json.RawMessage) error
- func (r *VKExecutor) SetMembers(ctx context.Context, key Key) ([]json.RawMessage, error)
- func (r *VKExecutor) SetRemove(ctx context.Context, key Key, member json.RawMessage) error
- func (r *VKExecutor) SetWithTTL(ctx context.Context, key Key, value json.RawMessage, ttl time.Duration) error
- type VKManager
Constants ¶
const SQLiteSchema = `` /* 194-byte string literal not displayed */
Schema is the DDL needed to bootstrap the kv store table in SQLite. Call this once after opening the database (NewSQLiteDBManager accepts a schema string).
Variables ¶
var ( ErrNotFound = errors.New("key not found") ErrInvalidValue = errors.New("invalid value for operation") ErrKeyExists = errors.New("key already exists") ErrTxFailed = errors.New("transaction failed") ErrTxConflict = errors.New("transaction conflict") ErrConnectionFailed = errors.New("connection failed") )
Functions ¶
func SetupLocalPDInstance ¶
func SetupLocalTiKVInstance ¶
Types ¶
type KVExecutor ¶
type KVExecutor interface {
Get(ctx context.Context, key Key) (json.RawMessage, error)
Set(ctx context.Context, key Key, value json.RawMessage) error
SetWithTTL(ctx context.Context, key Key, value json.RawMessage, ttl time.Duration) error
Delete(ctx context.Context, key Key) error
Exists(ctx context.Context, key Key) (bool, error)
Keys(ctx context.Context, pattern string) ([]Key, error)
// List operations
ListPush(ctx context.Context, key Key, value json.RawMessage) error
ListRange(ctx context.Context, key Key, start, stop int64) ([]json.RawMessage, error)
ListTrim(ctx context.Context, key Key, start, stop int64) error
ListLength(ctx context.Context, key Key) (int64, error)
ListRPop(ctx context.Context, key Key) (json.RawMessage, error)
// Set operations
SetAdd(ctx context.Context, key Key, member json.RawMessage) error
SetMembers(ctx context.Context, key Key) ([]json.RawMessage, error)
SetRemove(ctx context.Context, key Key, member json.RawMessage) error
}
KVExecutor is a non-transactional key-value backend.
type KVManager ¶
type KVManager interface {
Executor(ctx context.Context) (KVExecutor, error)
Close() error
}
KVManager obtains non-transactional KVExecutors.
type KeyValue ¶
type KeyValue struct {
Key string
Value json.RawMessage
TTL time.Time
}
KeyValue exists for backward compatibility with the old interface.
type SQLiteManager ¶
type SQLiteManager struct {
// contains filtered or unexported fields
}
SQLiteManager implements KVManager on top of a libdbexec.DBManager (SQLite).
func NewSQLiteManager ¶
func NewSQLiteManager(db libdbexec.DBManager) *SQLiteManager
NewSQLiteManager wraps an existing libdbexec.DBManager. The caller is responsible for opening the database and applying SQLiteSchema.
func (*SQLiteManager) Close ¶
func (m *SQLiteManager) Close() error
Close closes the underlying database.
func (*SQLiteManager) Executor ¶
func (m *SQLiteManager) Executor(_ context.Context) (KVExecutor, error)
Executor returns a KVExecutor bound to a non-transactional connection. The manager is handed along too, so list/set read-modify-write ops can open a real transaction; a bare libdbexec.Exec cannot start one.
type VKExecutor ¶
type VKExecutor struct {
// contains filtered or unexported fields
}
func (*VKExecutor) Get ¶
func (r *VKExecutor) Get(ctx context.Context, key Key) (json.RawMessage, error)
func (*VKExecutor) ListLength ¶
func (*VKExecutor) ListPush ¶
func (r *VKExecutor) ListPush(ctx context.Context, key Key, value json.RawMessage) error
func (*VKExecutor) ListRPop ¶
func (r *VKExecutor) ListRPop(ctx context.Context, key Key) (json.RawMessage, error)
func (*VKExecutor) ListRange ¶
func (r *VKExecutor) ListRange(ctx context.Context, key Key, start, stop int64) ([]json.RawMessage, error)
func (*VKExecutor) Set ¶
func (r *VKExecutor) Set(ctx context.Context, key Key, value json.RawMessage) error
func (*VKExecutor) SetAdd ¶
func (r *VKExecutor) SetAdd(ctx context.Context, key Key, member json.RawMessage) error
func (*VKExecutor) SetMembers ¶
func (r *VKExecutor) SetMembers(ctx context.Context, key Key) ([]json.RawMessage, error)
func (*VKExecutor) SetRemove ¶
func (r *VKExecutor) SetRemove(ctx context.Context, key Key, member json.RawMessage) error
func (*VKExecutor) SetWithTTL ¶
func (r *VKExecutor) SetWithTTL(ctx context.Context, key Key, value json.RawMessage, ttl time.Duration) error