caches

package
v1.0.19 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTooBigKey  = fmt.Errorf("key was too big, must not be greater than 63k")
	ErrInvalidKey = fmt.Errorf("key is invalid")
)

Functions

This section is empty.

Types

type Cache

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

func New

func New(maxBytes uint64) (cache *Cache)

func NewWithHash

func NewWithHash(maxBytes uint64, h Hash) (cache *Cache)

func (*Cache) Decr

func (c *Cache) Decr(k []byte, delta int64) (n int64, err error)

func (*Cache) Exist

func (c *Cache) Exist(k []byte) bool

func (*Cache) Expire

func (c *Cache) Expire(k []byte, ttl time.Duration) (err error)

func (*Cache) Get

func (c *Cache) Get(k []byte) ([]byte, bool)

func (*Cache) Incr

func (c *Cache) Incr(k []byte, delta int64) (n int64, err error)

func (*Cache) Remove

func (c *Cache) Remove(k []byte)

func (*Cache) Set

func (c *Cache) Set(k []byte, v []byte) (err error)

func (*Cache) SetWithTTL

func (c *Cache) SetWithTTL(k []byte, v []byte, ttl time.Duration) (err error)

type Hash

type Hash interface {
	Sum(p []byte) (h uint64)
}

type Increment

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

func (*Increment) Decr

func (incr *Increment) Decr(d int64) int64

func (*Increment) Expired

func (incr *Increment) Expired() bool

func (*Increment) Incr

func (incr *Increment) Incr(d int64) int64

func (*Increment) Rest

func (incr *Increment) Rest(d int64)

func (*Increment) Value

func (incr *Increment) Value() int64

type Increments

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

func (*Increments) Decr

func (increments *Increments) Decr(k uint64, delta int64) (n int64)

func (*Increments) Expire

func (increments *Increments) Expire(k uint64, ttl time.Duration)

func (*Increments) Incr

func (increments *Increments) Incr(k uint64, delta int64) (n int64)

func (*Increments) Remove

func (increments *Increments) Remove(k uint64)

func (*Increments) Value

func (increments *Increments) Value(k uint64) (n int64, has bool)

type Keys

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

func NewKeys

func NewKeys() *Keys

func (*Keys) Exist

func (m *Keys) Exist(key uint64) (has bool)

func (*Keys) Remove

func (m *Keys) Remove(key uint64)

func (*Keys) Set

func (m *Keys) Set(key uint64)

type LRU

type LRU[K ordered, V any] struct {
	// contains filtered or unexported fields
}

func NewLRU

func NewLRU[K ordered, V any](size uint32) (lru *LRU[K, V])

func (*LRU[K, V]) Add

func (c *LRU[K, V]) Add(key K, value V, ttl time.Duration) (evicted bool)

func (*LRU[K, V]) Get

func (c *LRU[K, V]) Get(key K) (value V, ok bool)

func (*LRU[K, V]) Keys

func (c *LRU[K, V]) Keys() []K

func (*LRU[K, V]) Len

func (c *LRU[K, V]) Len() int

func (*LRU[K, V]) Purge

func (c *LRU[K, V]) Purge()

func (*LRU[K, V]) Remove

func (c *LRU[K, V]) Remove(key K) (present bool)

func (*LRU[K, V]) Resize

func (c *LRU[K, V]) Resize(size int64) (evicted int64)

type MemHash

type MemHash struct{}

func (MemHash) Sum

func (hash MemHash) Sum(p []byte) (h uint64)

type XXHash

type XXHash struct{}

func (XXHash) Sum

func (hash XXHash) Sum(p []byte) (h uint64)

Jump to

Keyboard shortcuts

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