Documentation ¶
Overview ¶
Package memory implements backend interface using a combination of Minheap (to store expiring items) and B-Tree for storing sorted dictionary of items. This package is used for caching layer
Index ¶
- func GetName() string
- type Config
- type Memory
- func (m *Memory) Clock() clockwork.Clock
- func (m *Memory) Close() error
- func (m *Memory) CloseWatchers()
- func (m *Memory) CompareAndSwap(ctx context.Context, expected backend.Item, replaceWith backend.Item) (*backend.Lease, error)
- func (m *Memory) Create(ctx context.Context, i backend.Item) (*backend.Lease, error)
- func (m *Memory) Delete(ctx context.Context, key []byte) error
- func (m *Memory) DeleteRange(ctx context.Context, startKey, endKey []byte) error
- func (m *Memory) Get(ctx context.Context, key []byte) (*backend.Item, error)
- func (m *Memory) GetRange(ctx context.Context, startKey []byte, endKey []byte, limit int) (*backend.GetResult, error)
- func (m *Memory) KeepAlive(ctx context.Context, lease backend.Lease, expires time.Time) error
- func (m *Memory) NewWatcher(ctx context.Context, watch backend.Watch) (backend.Watcher, error)
- func (m *Memory) Put(ctx context.Context, i backend.Item) (*backend.Lease, error)
- func (m *Memory) PutRange(ctx context.Context, items []backend.Item) error
- func (m *Memory) Update(ctx context.Context, i backend.Item) (*backend.Lease, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // Context is a context for opening the // database Context context.Context // BTreeDegree is a degree of B-Tree, 2 for example, will create a // 2-3-4 tree (each node contains 1-3 items and 2-4 children). BTreeDegree int // Clock is a clock for time-related operations Clock clockwork.Clock // Component is a logging component Component string // EventsOff turns off events generation EventsOff bool // BufferSize sets up event buffer size BufferSize int // Mirror mode is used when the memory backend is used for caching. In mirror // mode, record IDs for Put and PutRange requests are re-used (instead of // generating fresh ones) and expiration is turned off. Mirror bool }
Config holds configuration for the backend
func (*Config) CheckAndSetDefaults ¶
CheckAndSetDefaults checks and sets default values
type Memory ¶
type Memory struct { *sync.Mutex *log.Entry Config backend.NoMigrations // contains filtered or unexported fields }
Memory is a memory B-Tree based backend
func (*Memory) CloseWatchers ¶
func (m *Memory) CloseWatchers()
CloseWatchers closes all the watchers without closing the backend
func (*Memory) CompareAndSwap ¶
func (m *Memory) CompareAndSwap(ctx context.Context, expected backend.Item, replaceWith backend.Item) (*backend.Lease, error)
CompareAndSwap compares item with existing item and replaces it with replaceWith item
func (*Memory) DeleteRange ¶
DeleteRange deletes range of items with keys between startKey and endKey Note that elements deleted by range do not produce any events
func (*Memory) GetRange ¶
func (m *Memory) GetRange(ctx context.Context, startKey []byte, endKey []byte, limit int) (*backend.GetResult, error)
GetRange returns query range
func (*Memory) NewWatcher ¶
NewWatcher returns a new event watcher
func (*Memory) Put ¶
Put puts value into backend (creates if it does not exists, updates it otherwise)