cache

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2016 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const RequestsBucketName = "rqbucket"

RequestsBucketName - default name for BoltDB bucket

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 request/response payloads or anything else

type InMemoryCache

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

Cache used for storing requests and responses 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() (count int, err error)

func (*InMemoryCache) Set

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

Jump to

Keyboard shortcuts

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