caches

package
v1.2.80 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 10 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) Contains added in v1.1.0

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

func (*Cache) Expire

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

func (*Cache) Get

func (c *Cache) Get(k []byte) (p []byte, ok 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 KV added in v1.1.0

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

func (KV) Hash added in v1.1.0

func (kv KV) Hash() uint64

func (KV) Key added in v1.1.0

func (kv KV) Key() []byte

func (KV) Value added in v1.1.0

func (kv KV) Value() Value

type KVS added in v1.1.0

type KVS []KV

func MakeKVS added in v1.1.0

func MakeKVS(k []byte, p []byte, ttl time.Duration, hash Hash) (kvs KVS)

func (KVS) Deadline added in v1.1.0

func (kvs KVS) Deadline() time.Time

func (KVS) Value added in v1.1.0

func (kvs KVS) Value() (p []byte)

type MemHash

type MemHash struct{}

func (MemHash) Sum

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

type Value added in v1.1.0

type Value []byte

Value [1]pos [1]size, [8]deadline, [...]value

func MakeValue added in v1.1.0

func MakeValue(p []byte) Value

func (Value) BigKey added in v1.1.0

func (v Value) BigKey() bool

func (Value) Bytes added in v1.1.0

func (v Value) Bytes() (p []byte)

func (Value) Deadline added in v1.1.0

func (v Value) Deadline() time.Time

func (Value) Normal added in v1.1.0

func (v Value) Normal() bool

func (Value) Pos added in v1.1.0

func (v Value) Pos() int

func (Value) SetDeadline added in v1.1.0

func (v Value) SetDeadline(deadline time.Time)

func (Value) Size added in v1.1.0

func (v Value) Size() int

type XXHash

type XXHash struct{}

func (XXHash) Sum

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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