sdcacheristretto

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sdcacheristretto 使用ristretto实现的cache

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func New

func New(c *ristretto.Cache, config Config) (*Cache, error)

func NewByRistrettoConfig

func NewByRistrettoConfig(ristrettoConfig ristretto.Config, config Config) (*Cache, error)

func (*Cache) Clear

func (c *Cache) Clear(ctx context.Context) error

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, k any) error

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, k any) (any, error)

func (*Cache) GetOrPut

func (c *Cache) GetOrPut(ctx context.Context, k any, loader func(ctx context.Context, k any) (any, error), opts *sdcache.PutOptions) (any, error)

func (*Cache) GetTTL

func (c *Cache) GetTTL(ctx context.Context, k any) (time.Duration, error)

func (*Cache) Put

func (c *Cache) Put(ctx context.Context, k, v any, opts *sdcache.PutOptions) error

func (*Cache) Ristretto

func (c *Cache) Ristretto() *ristretto.Cache

func (*Cache) SetCost

func (c *Cache) SetCost(cost int64) *Cache

func (*Cache) SetKey

func (c *Cache) SetKey(key sdcache.Key) *Cache

func (*Cache) SetTTL

func (c *Cache) SetTTL(ttl time.Duration) *Cache

type Config

type Config struct {
	Key  sdcache.Key
	TTL  time.Duration
	Cost int64
}

Jump to

Keyboard shortcuts

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