memorydb

package
v0.0.0-...-a048d37 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLRUCache

func NewLRUCache(capacity int) db.Database

NewLRUCache New function

Types

type LRUCache

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

LRUCache cache struct

func (*LRUCache) Close

func (c *LRUCache) Close()

func (*LRUCache) Delete

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

Del delete cached value from cache Params:

  • key: cache key

func (*LRUCache) EnlargeCapacity

func (c *LRUCache) EnlargeCapacity(newCapacity int) error

EnlargeCapacity enlarge the capacity of cache

func (*LRUCache) Get

func (c *LRUCache) Get(key []byte) ([]byte, error)

Get get cached value from LRU cache Params:

  • key: cache key

Return:

  • value: cache value
  • ok : true if found, false if not

func (*LRUCache) Keys

func (c *LRUCache) Keys() []interface{}

Keys get keys of items in cache

func (*LRUCache) Len

func (c *LRUCache) Len() int

Len get number of items in cache

func (*LRUCache) Put

func (c *LRUCache) Put(key []byte, value []byte) error

Add add a key-value pair to LRU cache Params:

  • key : cache key
  • value: cache value

Return:

  • evictOrNot: true if eviction occurs, false if not

type Pair

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

Pair <key, value>

Jump to

Keyboard shortcuts

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