cache

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PlanCacheEnabled stores the global config "plan-cache-enabled".
	PlanCacheEnabled bool
	// PlanCacheShards stores the global config "plan-cache-shards".
	PlanCacheShards int64
	// PlanCacheCapacity stores the global config "plan-cache-capacity".
	PlanCacheCapacity int64
	// GlobalPlanCache stores the global plan cache for every session in a tidb-server.
	GlobalPlanCache *ShardedLRUCache
)

Functions

This section is empty.

Types

type Key

type Key interface {
	Hash() []byte
}

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

func NewSQLCacheKey

func NewSQLCacheKey(sessionVars *variable.SessionVars, sql string, schemaVersion int64, readOnly bool) Key

NewSQLCacheKey creates a new sqlCacheKey object.

type SQLCacheValue

type SQLCacheValue struct {
	StmtNode  ast.StmtNode
	Plan      plan.Plan
	Expensive bool
}

SQLCacheValue stores the cached Statement and StmtNode.

func NewSQLCacheValue

func NewSQLCacheValue(ast ast.StmtNode, plan plan.Plan, expensive bool) *SQLCacheValue

NewSQLCacheValue creates a SQLCacheValue.

type ShardedLRUCache

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

ShardedLRUCache is a sharded LRU Cache, thread safe.

func NewShardedLRUCache

func NewShardedLRUCache(capacity, shardCount int64) *ShardedLRUCache

NewShardedLRUCache creates a ShardedLRUCache.

func (*ShardedLRUCache) Get

func (s *ShardedLRUCache) Get(key Key) (Value, bool)

Get gets a value from a ShardedLRUCache.

func (*ShardedLRUCache) Put

func (s *ShardedLRUCache) Put(key Key, value Value)

Put puts a (key, value) pair to a ShardedLRUCache.

type SimpleLRUCache

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

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

func NewSimpleLRUCache

func NewSimpleLRUCache(capacity int64) *SimpleLRUCache

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

func (*SimpleLRUCache) Get

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

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

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

type Value

type Value interface {
}

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

Jump to

Keyboard shortcuts

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