cache

package
v0.0.0-...-92e1235 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: MIT Imports: 4 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 []byte, ttl time.Duration)
	Get(key string) ([]byte, bool)
	Delete(key string)
}

type EvictPolicy

type EvictPolicy string
const (
	EvictNO  EvictPolicy = "EvictNO"
	EvictLRU EvictPolicy = "EvictLRU"
)

type InMemCache

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

func NewInMemCache

func NewInMemCache(cleanupInterval time.Duration, evictPolicy EvictPolicy, opt ...InMemCacheOption) *InMemCache

func (*InMemCache) Delete

func (c *InMemCache) Delete(key string)

func (*InMemCache) Get

func (c *InMemCache) Get(key string) ([]byte, bool)

func (*InMemCache) Set

func (c *InMemCache) Set(key string, value []byte, ttl time.Duration)

func (*InMemCache) Stop

func (c *InMemCache) Stop()

type InMemCacheOption

type InMemCacheOption func(*InMemCache)

func WithEvictInterval

func WithEvictInterval(interval time.Duration) InMemCacheOption

type InMemItem

type InMemItem struct {
	Value      []byte
	TTL        int64
	AccessTime int64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳