cache

package
v0.0.0-...-d37e48f Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Set(key string, value interface{}, expiration time.Duration) error
	Get(key string) (interface{}, bool)
	Delete(key string) error
}

func NewCacheFromConfig

func NewCacheFromConfig(config config.Config) (Cache, error)

type CacheItem

type CacheItem struct {
	Key        string
	Value      interface{}
	Expiration int64
}

CacheItem represents a single cache item

type LocalCache

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

LocalCache is an in-memory cache implementation with a maximum size and LRU eviction policy

func NewLocalCache

func NewLocalCache(maxSize int) *LocalCache

NewLocalCache initializes a new in-memory cache with a maximum size

func (*LocalCache) Delete

func (c *LocalCache) Delete(key string) error

Delete removes an item from the cache

func (*LocalCache) Get

func (c *LocalCache) Get(key string) (interface{}, bool)

Get retrieves an item from the cache

func (*LocalCache) Set

func (c *LocalCache) Set(key string, value interface{}, expiration time.Duration) error

Set adds an item to the cache

type RedisCache

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

func NewRedisCache

func NewRedisCache(addr string, password string, db int) (*RedisCache, error)

func (*RedisCache) Delete

func (r *RedisCache) Delete(key string) error

func (*RedisCache) Get

func (r *RedisCache) Get(key string) (interface{}, bool)

func (*RedisCache) Set

func (r *RedisCache) Set(key string, value interface{}, expiration time.Duration) error

Jump to

Keyboard shortcuts

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