ristretto

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New[V any](level string) (cache.Cache[string, V], error)

New creates a new Ristretto cache instance based on a predefined level.

Types

type Cache

type Cache[V any] struct {
	// contains filtered or unexported fields
}

Cache wrapper specialized for string keys. It remains generic over the value type V.

func (*Cache[V]) Get

func (rc *Cache[V]) Get(key string) (V, bool)

Get retrieves a value using a string key.

func (*Cache[V]) Set

func (rc *Cache[V]) Set(key string, value V, cost int64) bool

Set stores a value with a string key.

func (*Cache[V]) SetWithTTL

func (rc *Cache[V]) SetWithTTL(key string, value V, cost int64, ttl time.Duration) bool

SetWithTTL stores a value with a string key and TTL.

type CacheParams added in v0.4.0

type CacheParams struct {
	NumCounters int64
	MaxCost     int64
	BufferItems int64
}

CacheParams holds the configuration for a Ristretto cache instance.

Jump to

Keyboard shortcuts

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