acdb

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: MIT Imports: 6 Imported by: 0

README

Acdb

Package acdb manages objects between memory and file system.

Acdb is a highly available NoSQL data store that offloads the work of database administration. Developers simply set and get k/v data from memory and file system and Acdb does the rest.

Documentation

Overview

Package acdb manages objects between memory and file system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a actuator of the given drive. Do not worry, Is's concurrency-safety.

func Doc

func Doc(root string) *Client

Doc returns a concurrency-safety Client with DocDriver.

func Lru

func Lru(size int) *Client

Lru returns a concurrency-safety Client with LruDriver.

func Map

func Map(root string) *Client

Map returns a concurrency-safety Client with MapDriver.

func Mem

func Mem() *Client

Mem returns a concurrency-safety Client with MemDriver.

func NewClient

func NewClient(driver Driver) *Client

NewClient returns a Client.

func (*Client) Del

func (e *Client) Del(k string) error

Del the value of a key.

func (*Client) Get

func (e *Client) Get(k string) ([]byte, error)

Get the value of a key.

func (*Client) GetDecode

func (e *Client) GetDecode(k string, v any) error

GetDecode get the decoded value of a key.

func (*Client) GetFloat32

func (e *Client) GetFloat32(k string) (float32, error)

GetFloat32 get the float32 value of a key.

func (*Client) GetFloat64

func (e *Client) GetFloat64(k string) (float64, error)

GetFloat64 get the float64 value of a key.

func (*Client) GetInt

func (e *Client) GetInt(k string) (int, error)

GetInt get the int value of a key.

func (*Client) GetInt32

func (e *Client) GetInt32(k string) (int32, error)

GetInt32 get the int32 value of a key.

func (*Client) GetInt64

func (e *Client) GetInt64(k string) (int64, error)

GetInt64 get the int64 value of a key.

func (*Client) GetString

func (e *Client) GetString(k string) (string, error)

GetString get the string value of a key.

func (*Client) GetUint

func (e *Client) GetUint(k string) (uint, error)

GetUint get the uint value of a key.

func (*Client) GetUint32

func (e *Client) GetUint32(k string) (uint32, error)

GetUint32 get the uint32 value of a key.

func (*Client) GetUint64

func (e *Client) GetUint64(k string) (uint64, error)

GetUint64 get the uint64 value of a key.

func (*Client) Has

func (e *Client) Has(k string) bool

Has determine if a key exists.

func (*Client) Log

func (e *Client) Log(l int)

Log set the log level.

func (*Client) Nil

func (e *Client) Nil(k string) bool

Nil determine if a key emptys.

func (*Client) Set

func (e *Client) Set(k string, v []byte) error

Set the value of a key.

func (*Client) SetEncode

func (e *Client) SetEncode(k string, v any) error

SetEncode set the encoded value of a key.

type DocDriver

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

DocDriver use the OS's file system to manage data. In general, any high frequency operation is not recommended unless you have an enough reason.

func NewDocDriver

func NewDocDriver(root string) *DocDriver

NewDocDriver returns a DocDriver.

func (*DocDriver) Del

func (d *DocDriver) Del(k string) error

Del the value of a key.

func (*DocDriver) Get

func (d *DocDriver) Get(k string) ([]byte, error)

Get the value of a key.

func (*DocDriver) Set

func (d *DocDriver) Set(k string, v []byte) error

Set the value of a key.

type Driver

type Driver interface {
	Get(k string) ([]byte, error)
	Set(k string, v []byte) error
	Del(k string) error
}

Driver is the interface that wraps the Set/Get and Del method.

Get gets and returns the bytes or any error encountered. If the key does not exist, ErrNotExist will be returned. Set sets bytes with given k. Del dels bytes with given k. If the key does not exist, ErrNotExist will be returned.

type LruDriver

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

LruDriver implemention. In computing, cache algorithms (also frequently called cache replacement algorithms or cache replacement policies) are optimizing instructions, or algorithms, that a computer program or a hardware-maintained structure can utilize in order to manage a cache of information stored on the computer. Caching improves performance by keeping recent or often-used data items in a memory locations that are faster or computationally cheaper to access than normal memory stores. When the cache is full, the algorithm must choose which items to discard to make room for the new ones.

Least recently used (LRU), discards the least recently used items first. It has a fixed size(for limit memory usages) and O(1) time lookup.

func NewLruDriver

func NewLruDriver(size int) *LruDriver

NewLruDriver returns a LruDriver.

func (*LruDriver) Del

func (d *LruDriver) Del(k string) error

Del the value of a key.

func (*LruDriver) Get

func (d *LruDriver) Get(k string) ([]byte, error)

Get the value of a key.

func (*LruDriver) Set

func (d *LruDriver) Set(k string, v []byte) error

Set the value of a key.

type MapDriver

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

MapDriver is based on DocDriver and use LruDriver to provide caching at its interface layer. The size of LruDriver is always 1024.

func NewMapDriver

func NewMapDriver(root string) *MapDriver

NewMapDriver returns a MapDriver.

func (*MapDriver) Del

func (d *MapDriver) Del(k string) error

Del the value of a key.

func (*MapDriver) Get

func (d *MapDriver) Get(k string) ([]byte, error)

Get the value of a key.

func (*MapDriver) Set

func (d *MapDriver) Set(k string, v []byte) error

Set the value of a key.

type MemDriver

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

MemDriver cares to store data on memory, this means that MemDriver is fast. Since there is no expiration mechanism, be careful that it might eats up all your memory.

func NewMemDriver

func NewMemDriver() *MemDriver

NewMemDriver returns a MemDriver.

func (*MemDriver) Del

func (d *MemDriver) Del(k string) error

Del the value of a key.

func (*MemDriver) Get

func (d *MemDriver) Get(k string) ([]byte, error)

Get the value of a key.

func (*MemDriver) Set

func (d *MemDriver) Set(k string, v []byte) error

Set the value of a key.

Jump to

Keyboard shortcuts

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