Versions in this module Expand all Collapse all v0 v0.1.0 Mar 29, 2017 Changes in this version + const MaxShards + const MaxValueSize + const MinShardSize + var DefualtCacheOptions = CacheOptions + var DefualtShardOptions = ShardOptions + var ErrHeader = errors.New("header err") + var ErrIntOverflowIndex = fmt.Errorf("proto: integer overflow") + var ErrInvalidLengthIndex = fmt.Errorf("proto: negative length found during unmarshaling") + var ErrNotFound = errors.New("key not found") + var ErrOutOfRange = errors.New("out of data range") + var ErrShortRead = errors.New("short read") + var ErrValueSize = errors.New("value size exceeded") + type Allocator interface + Free func([]byte) + Malloc func(n int) []byte + func NewAllocatorPool() Allocator + type AllocatorPool struct + func (p *AllocatorPool) Free(b []byte) + func (p *AllocatorPool) GetMetrics() AllocatorPoolMetrics + func (p *AllocatorPool) Malloc(n int) []byte + type AllocatorPoolMetrics struct + ErrFree int64 + ErrMalloc int64 + Free int64 + Malloc int64 + New int64 + type Cache struct + func NewCache(path string, options *CacheOptions) (*Cache, error) + func (c *Cache) Close() error + func (c *Cache) Del(key string) error + func (c *Cache) Get(key string) (Item, error) + func (c *Cache) GetMetrics() CacheMetrics + func (c *Cache) GetMetricsByShards() []CacheMetrics + func (c *Cache) GetOptions() CacheOptions + func (c *Cache) GetStats() CacheStats + func (c *Cache) GetStatsByShards() []CacheStats + func (c *Cache) Set(item Item) error + type CacheData struct + func LoadCacheData(fn string, sz int64) (*CacheData, error) + func (d *CacheData) Close() error + func (d *CacheData) Read(offset int64, b []byte) error + func (d *CacheData) Size() int64 + func (d *CacheData) Write(offset int64, b []byte) error + type CacheIndex struct + func LoadCacheIndex(fn string, datasize int64) (*CacheIndex, error) + func (i *CacheIndex) Close() error + func (i *CacheIndex) Del(key string) error + func (i *CacheIndex) Dels(keys []string) error + func (i *CacheIndex) Get(key string) (*IndexItem, error) + func (i *CacheIndex) GetIndexMeta() IndexMeta + func (i *CacheIndex) GetKeys() (n uint64, err error) + func (i *CacheIndex) Iter(lastkey string, maxIter int, f func(key string, item IndexItem) error) error + func (i *CacheIndex) Reserve(size int32) (*IndexItem, error) + func (i *CacheIndex) Set(key string, item *IndexItem) error + type CacheMetrics struct + DelTotal int64 + Evicted int64 + EvictedAge int64 + Expired int64 + GetExpired int64 + GetHits int64 + GetMisses int64 + GetTotal int64 + SetTotal int64 + func (m *CacheMetrics) Add(o CacheMetrics) + type CacheOptions struct + Allocator Allocator + ShardNum int + Size int64 + TTL int64 + type CacheStats struct + Bytes uint64 + Keys uint64 + LastUpdate int64 + func (st *CacheStats) Add(o CacheStats) + type ConsistentHash struct + func NewConsistentHashTable(n int) ConsistentHash + func (c *ConsistentHash) Get(key string) int + type IndexItem struct + Flags uint32 + Offset int64 + TTL uint32 + Term int64 + Timestamp int64 + ValueSize int32 + func (*IndexItem) Descriptor() ([]byte, []int) + func (*IndexItem) ProtoMessage() + func (i IndexItem) TotalSize() int64 + func (m *IndexItem) Marshal() (data []byte, err error) + func (m *IndexItem) MarshalTo(data []byte) (int, error) + func (m *IndexItem) Reset() + func (m *IndexItem) Size() (n int) + func (m *IndexItem) String() string + func (m *IndexItem) Unmarshal(data []byte) error + type IndexMeta struct + DataSize int64 + Head int64 + Term int64 + func (*IndexMeta) Descriptor() ([]byte, []int) + func (*IndexMeta) ProtoMessage() + func (m *IndexMeta) Marshal() (data []byte, err error) + func (m *IndexMeta) MarshalTo(data []byte) (int, error) + func (m *IndexMeta) Reset() + func (m *IndexMeta) Size() (n int) + func (m *IndexMeta) String() string + func (m *IndexMeta) Unmarshal(data []byte) error + func (m IndexMeta) IsValidate(i IndexItem) bool + type Item struct + Flags uint32 + Key string + TTL uint32 + Timestamp int64 + Value []byte + func (i *Item) Free() + type Shard struct + func LoadCacheShard(fn string, options *ShardOptions) (*Shard, error) + func (s *Shard) Close() error + func (s *Shard) Del(key string) error + func (s *Shard) GCLoop() + func (s *Shard) Get(key string) (Item, error) + func (s *Shard) GetMetrics() CacheMetrics + func (s *Shard) GetStats() CacheStats + func (s *Shard) Set(ci Item) error + type ShardOptions struct + Allocator Allocator + Size int64 + TTL int64