ttlcache: Index | Files

package ttlcache

import ""


Package Files

key.go ttlcache.go

func AnyKey Uses

func AnyKey(k interface{}) uint64

AnyKey creates key from anything. Should not be used for large datasets. For complex keys you can write your own hashing implementation.

func ByteKey Uses

func ByteKey(k byte) uint64

ByteKey creates key from byte value.

func BytesKey Uses

func BytesKey(k []byte) uint64

BytesKey creates key from slice of bytes value.

func Int16Key Uses

func Int16Key(k int16) uint64

Int16Key creates key from int16 value.

func Int32Key Uses

func Int32Key(k int32) uint64

Int32Key creates key from int32 value.

func Int64Key Uses

func Int64Key(k int64) uint64

Int64Key creates key from int64 value.

func Int8Key Uses

func Int8Key(k int8) uint64

Int8Key creates key from int8 value.

func IntKey Uses

func IntKey(k int) uint64

IntKey creates key from int value.

func StringKey Uses

func StringKey(k string) uint64

StringKey creates key from string value.

func Uint16Key Uses

func Uint16Key(k uint16) uint64

Uint16Key creates key from uint16 value.

func Uint32Key Uses

func Uint32Key(k uint32) uint64

Uint32Key creates key from uint32 value.

func Uint64Key Uses

func Uint64Key(k uint64) uint64

Uint64Key creates key from uint64 value.

func Uint8Key Uses

func Uint8Key(k uint8) uint64

Uint8Key creates key from uint8 value.

type Cache Uses

type Cache struct {
    // contains filtered or unexported fields

Cache represents key-value storage.

func New Uses

func New(resolution time.Duration) *Cache

New creates key-value storage. resolution – configures cleanup manager. Cleanup operation locks storage so think twice before setting it to small value.

func (*Cache) Close Uses

func (c *Cache) Close() error

Close stops cleanup manager and removes records from storage.

func (*Cache) Delete Uses

func (c *Cache) Delete(key uint64)

Delete removes record from storage.

func (*Cache) Get Uses

func (c *Cache) Get(key uint64) (interface{}, bool)

Get returns stored record. The first returned variable is a stored value. The second one is an existence flag like in the map.

func (*Cache) Set Uses

func (c *Cache) Set(key uint64, value interface{}, ttl time.Duration)

Set adds value to the cache with given ttl. ttl value should be a multiple of the resolution time value.

Package ttlcache imports 4 packages (graph). Updated 2021-01-13. Refresh now. Tools for package owners.