sqlitebk

package
v0.0.0-...-8d1852a Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromJSON

func FromJSON(paramsJSON string) (backend.Backend, error)

func FromObject

func FromObject(in interface{}) (backend.Backend, error)

FromString initialized the backend from backend-specific string

Types

type Option

type Option func(b *SQLiteBackend) error

Option sets functional options for the backend

func Clock

func Clock(clock timetools.TimeProvider) Option

Clock sets clock for the backend, used in tests

type SQLiteBackend

type SQLiteBackend struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(path string, opts ...Option) (*SQLiteBackend, error)

func NewBackendFromDB

func NewBackendFromDB(db *sql.DB, opts ...Option) (*SQLiteBackend, error)

func (*SQLiteBackend) AcquireLock

func (sb *SQLiteBackend) AcquireLock(token string, ttl time.Duration) error

AcquireLock grabs a lock that will be released automatically in TTL

func (*SQLiteBackend) Close

func (sb *SQLiteBackend) Close() error

Close releases the resources taken up by this backend

func (*SQLiteBackend) CompareAndSwap

func (sb *SQLiteBackend) CompareAndSwap(bucket []string, key string, val []byte, ttl time.Duration, prevVal []byte) ([]byte, error)

CompareAndSwap implements compare ans swap operation for a key

func (*SQLiteBackend) CreateVal

func (sb *SQLiteBackend) CreateVal(bucket []string, key string, val []byte, ttl time.Duration) error

CreateVal creates value with a given TTL and key in the bucket if the value already exists, returns AlreadyExistsError

func (*SQLiteBackend) DeleteBucket

func (sb *SQLiteBackend) DeleteBucket(bucket []string, bkt string) error

DeleteBucket deletes the bucket by a given path

func (*SQLiteBackend) DeleteKey

func (sb *SQLiteBackend) DeleteKey(bucket []string, key string) error

DeleteKey deletes a key in a bucket

func (*SQLiteBackend) GetKeys

func (sb *SQLiteBackend) GetKeys(bucket []string) ([]string, error)

GetKeys returns a list of keys for a given path

func (*SQLiteBackend) GetVal

func (sb *SQLiteBackend) GetVal(bucket []string, key string) ([]byte, error)

GetVal return a value for a given key in the bucket

func (*SQLiteBackend) GetValAndTTL

func (sb *SQLiteBackend) GetValAndTTL(bucket []string, key string) ([]byte, time.Duration, error)

GetValAndTTL returns value and TTL for a key in bucket

func (*SQLiteBackend) ReleaseLock

func (sb *SQLiteBackend) ReleaseLock(token string) error

ReleaseLock forces lock release before TTL

func (*SQLiteBackend) TouchVal

func (sb *SQLiteBackend) TouchVal(bucket []string, key string, ttl time.Duration) error

TouchVal updates the TTL of the key without changing the value

func (*SQLiteBackend) UpsertVal

func (sb *SQLiteBackend) UpsertVal(bucket []string, key string, val []byte, ttl time.Duration) error

UpsertVal updates or inserts value with a given TTL into a bucket ForeverTTL for no TTL

Jump to

Keyboard shortcuts

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