cache

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2020 License: Apache-2.0 Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDB

func GetDB(name string) *bolt.DB

GetDB - returns open BoltDB database with read/write permissions or goes down in flames if something bad happends

Types

type BoltCache

type BoltCache struct {
	DS            *bolt.DB
	CurrentBucket []byte
}

BoltCache - container to implement Cache instance with BoltDB backend for storage

func NewBoltDBCache

func NewBoltDBCache(db *bolt.DB, bucket []byte) *BoltCache

NewBoltDBCache - returns new BoltCache instance

func (*BoltCache) Delete

func (c *BoltCache) Delete(key []byte) error

Delete - deletes specified key

func (*BoltCache) DeleteBucket

func (c *BoltCache) DeleteBucket(name []byte) (err error)

DeleteBucket - deletes bucket with all saved data

func (*BoltCache) DeleteData

func (c *BoltCache) DeleteData() error

DeleteData - deletes bucket with all saved data

func (*BoltCache) Get

func (c *BoltCache) Get(key []byte) (value []byte, err error)

Get - searches for given key in the cache and returns value if found

func (*BoltCache) GetAllEntries

func (c *BoltCache) GetAllEntries() (values map[string][]byte, err error)

GetAllEntries - returns all keys/values

func (*BoltCache) GetAllKeys

func (c *BoltCache) GetAllKeys() (keys map[string]bool, err error)

GetAllKeys - gets all current keys

func (*BoltCache) GetAllValues

func (c *BoltCache) GetAllValues() (values [][]byte, err error)

GetAllValues - returns all values

func (*BoltCache) RecordsCount

func (c *BoltCache) RecordsCount() (count int, err error)

RecordsCount - returns records count

func (*BoltCache) Set

func (c *BoltCache) Set(key, value []byte) error

Set - saves given key and value pair to cache

type Cache

type Cache interface {
	Set(key, value []byte) error
	Get(key []byte) ([]byte, error)
	GetAllValues() ([][]byte, error)
	GetAllEntries() (map[string][]byte, error)
	RecordsCount() (int, error)
	Delete(key []byte) error
	DeleteData() error
	GetAllKeys() (map[string]bool, error)
}

Cache - cache interface used to store and retrieve serialized data

type FastCache added in v1.0.0

type FastCache interface {
	Set(key, value interface{}) error
	Get(key interface{}) (interface{}, bool)
	GetAllEntries() (map[interface{}]interface{}, error)
	RecordsCount() (int, error)
	DeleteData() error
}

FastCache - cache interface used to store and retrieve any data type which requires no serialization

type InMemoryCache

type InMemoryCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Cache used for storing serialized data in memory

func NewInMemoryCache

func NewInMemoryCache() *InMemoryCache

func (*InMemoryCache) Delete

func (c *InMemoryCache) Delete(key []byte) error

func (*InMemoryCache) DeleteData

func (c *InMemoryCache) DeleteData() (err error)

func (*InMemoryCache) Get

func (c *InMemoryCache) Get(key []byte) (value []byte, err error)

func (*InMemoryCache) GetAllEntries

func (c *InMemoryCache) GetAllEntries() (map[string][]byte, error)

func (*InMemoryCache) GetAllKeys

func (c *InMemoryCache) GetAllKeys() (keys map[string]bool, err error)

func (*InMemoryCache) GetAllValues

func (c *InMemoryCache) GetAllValues() (values [][]byte, err error)

func (*InMemoryCache) RecordsCount

func (c *InMemoryCache) RecordsCount() (int, error)

func (*InMemoryCache) Set

func (c *InMemoryCache) Set(key, value []byte) (err error)

type LRUFastCache added in v1.0.0

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

Fixed size LRU cache for storing any data type

func NewDefaultLRUCache added in v1.0.0

func NewDefaultLRUCache() *LRUFastCache

func NewLRUCache added in v1.0.0

func NewLRUCache(size int) (*LRUFastCache, error)

func (*LRUFastCache) DeleteData added in v1.0.0

func (c *LRUFastCache) DeleteData() (err error)

func (*LRUFastCache) Get added in v1.0.0

func (c *LRUFastCache) Get(key interface{}) (value interface{}, found bool)

func (*LRUFastCache) GetAllEntries added in v1.0.0

func (c *LRUFastCache) GetAllEntries() (map[interface{}]interface{}, error)

func (*LRUFastCache) RecordsCount added in v1.0.0

func (c *LRUFastCache) RecordsCount() (count int, err error)

func (*LRUFastCache) Set added in v1.0.0

func (c *LRUFastCache) Set(key, value interface{}) (err error)

Jump to

Keyboard shortcuts

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