Documentation
¶
Index ¶
- type Config
- type Database
- func (d *Database) Close() error
- func (d *Database) Del(ctx context.Context, key string) error
- func (d *Database) DelAll(ctx context.Context) error
- func (d *Database) Exists(ctx context.Context, key string) (bool, error)
- func (d *Database) Get(ctx context.Context, key string) ([]byte, bool, error)
- func (d *Database) MultiDel(ctx context.Context, keys []string) error
- func (d *Database) MultiGet(ctx context.Context, keys []string) (map[string][]byte, error)
- func (d *Database) MultiSet(ctx context.Context, valMap map[string][]byte) error
- func (d *Database) MultiSetWithTTL(ctx context.Context, valMap map[string][]byte, expiration time.Duration) error
- func (d *Database) Set(ctx context.Context, key string, val []byte) error
- func (d *Database) SetWithTTL(ctx context.Context, key string, val []byte, expiration time.Duration) error
- func (d *Database) Sync() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Path string `json:"path"`
}
Config holds configuration options for BadgerDB.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is a BadgerDB-backed cache implementation that provides persistent key-value storage. It implements the ByteCache interface using BadgerDB as the underlying storage engine.
func NewDatabase ¶
NewDatabase creates a new BadgerDB cache with the specified configuration. It opens a BadgerDB instance at the configured path with default options.
func NewDatabaseWithBadger ¶
NewDatabaseWithBadger creates a new Database wrapper around an existing BadgerDB instance. This allows for advanced configuration and sharing of BadgerDB instances.
func NewDatabaseWithOptions ¶
NewDatabaseWithOptions creates a new BadgerDB cache with custom BadgerDB options. This provides full control over BadgerDB configuration such as compression, encryption, etc.