tidb: github.com/pingcap/tidb/util/kvcache Index | Files

package kvcache

import "github.com/pingcap/tidb/util/kvcache"

Index

Package Files

simple_lru.go

type Key Uses

type Key interface {
    Hash() []byte
}

Key is the interface that every key in LRU Cache should implement.

type SimpleLRUCache Uses

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

SimpleLRUCache is a simple least recently used cache, not thread-safe, use it carefully.

func NewSimpleLRUCache Uses

func NewSimpleLRUCache(capacity uint, guard float64, quota uint64) *SimpleLRUCache

NewSimpleLRUCache creates a SimpleLRUCache object, whose capacity is "capacity". NOTE: "capacity" should be a positive value.

func (*SimpleLRUCache) Delete Uses

func (l *SimpleLRUCache) Delete(key Key)

Delete deletes the key-value pair from the LRU Cache.

func (*SimpleLRUCache) DeleteAll Uses

func (l *SimpleLRUCache) DeleteAll()

DeleteAll deletes all elements from the LRU Cache.

func (*SimpleLRUCache) Get Uses

func (l *SimpleLRUCache) Get(key Key) (value Value, ok bool)

Get tries to find the corresponding value according to the given key.

func (*SimpleLRUCache) Put Uses

func (l *SimpleLRUCache) Put(key Key, value Value)

Put puts the (key, value) pair into the LRU Cache.

func (*SimpleLRUCache) Size Uses

func (l *SimpleLRUCache) Size() int

Size gets the current cache size.

func (*SimpleLRUCache) Values Uses

func (l *SimpleLRUCache) Values() []Value

Values return all values in cache.

type Value Uses

type Value interface {
}

Value is the interface that every value in LRU Cache should implement.

Package kvcache imports 2 packages (graph) and is imported by 68 packages. Updated 2019-09-16. Refresh now. Tools for package owners.