Documentation ¶
Index ¶
- Constants
- Variables
- func FastRand() uint32
- func FastRand64() uint64
- func GetNanoSec() int64
- func GetSec() uint32
- func MemHash(str string) uint64
- func SizeUvarint(x uint64) int
- type GigaCache
- 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 HashFn
- type Idx
- type Key
- type Options
- type Stats
- type Walker
Constants ¶
View Source
const (
KB = 1024
)
Variables ¶
Functions ¶
func FastRand64 ¶
func FastRand64() uint64
func MemHash ¶
MemHash is the hash function used by go map, it utilizes available hardware instructions (behaves as aes hash if aes instruction is available). NOTE: The hash seed changes for every process. So, this cannot be used as a persistent hash.
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 eliminate algorithm. // the higher the frequency, the more expired key-value pairs will be evicted, // but accordingly it will slow down the overall performance, // because the system needs to spend more time on probing and evicting. EvictInterval uint8 // DisableEvict // Set `true` when you don't need any expiration times. DisableEvict bool // Migrate threshold for a bucket to trigger a migration. MigrateRatio float64 // HashFn is custom hash function, default is runtime.memhash. HashFn HashFn // ConcurrencySafe specifies whether RWLocker are required for multithreading safety. ConcurrencySafe bool }
Options is the configuration of GigaCache.
type Stats ¶
type Stats struct { Len int Conflicts 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.