Documentation ¶
Index ¶
- Constants
- Variables
- func FastRand() uint32
- func FastRand64() uint64
- func SizeUvarint(x uint64) int
- type GigaCache
- func (c *GigaCache) EvictExpiredKeys()
- func (c *GigaCache) Get(keyStr string) ([]byte, int64, bool)
- func (c *GigaCache) GetStats() (stats Stats)
- func (c *GigaCache) Migrate()
- func (c *GigaCache) Remove(keyStr string) bool
- func (c *GigaCache) Scan(callback Walker)
- func (c *GigaCache) Set(keyStr string, value []byte) bool
- func (c *GigaCache) SetEx(keyStr string, value []byte, duration time.Duration) bool
- func (c *GigaCache) SetTTL(keyStr string, expiration int64) bool
- func (c *GigaCache) SetTx(keyStr string, value []byte, expiration int64) bool
- type Idx
- type Key
- type Options
- type Stats
- type Walker
Constants ¶
View Source
const (
KB = 1024
)
Variables ¶
View Source
var DefaultOptions = Options{ ShardCount: 1024, IndexSize: 1024, BufferSize: 64 * KB, EvictInterval: 5, MigrateRatio: 0.4, ConcurrencySafe: true, }
Functions ¶
func FastRand64 ¶
func FastRand64() uint64
Types ¶
type GigaCache ¶
type GigaCache struct {
// contains filtered or unexported fields
}
GigaCache implements a key-value cache.
func (*GigaCache) Migrate ¶
func (c *GigaCache) Migrate()
Migrate transfers all data to new buckets.
func (*GigaCache) Scan ¶
Scan iterates over all alive key-value pairs without copying the data. DO NOT MODIFY the bytes as they are not copied.
type Options ¶
type Options struct { // ShardCount is shard numbers of cache. ShardCount uint32 // Default size of the bucket initial. IndexSize int BufferSize int // EvictInterval indicates the frequency of execution of the evict algorithm. // if n >= 0, evict algorithm auto perform every `n` times write. // if n < 0, evict is disabled. EvictInterval int // Migrate threshold for a bucket to trigger a migration. MigrateRatio float64 // ConcurrencySafe specifies whether RWLocker are required for multithreading safety. ConcurrencySafe bool }
Options is the configuration of GigaCache.
type Stats ¶
type Stats struct { Len int Alloc uint64 Unused uint64 Migrates uint64 Evictions uint64 Probes uint64 }
Stats represents the runtime statistics of GigaCache.
func (Stats) EvictionRate ¶
EvictionRate calculates the percentage of evictions relative to probes.
func (Stats) UnusedRate ¶
UnusedRate calculates the percentage of unused space in the cache.
Click to show internal directories.
Click to hide internal directories.