cache

package
v0.0.0-...-f2f9726 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: Apache-2.0 Imports: 5 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[T any] struct {
	// contains filtered or unexported fields
}

Cache freecache实现

func NewCache

func NewCache[T any](size int) *Cache[T]

NewCache 创建新的freecache实例

func (*Cache[T]) Clear

func (l *Cache[T]) Clear() error

Clear 清空缓存

func (*Cache[T]) Get

func (l *Cache[T]) Get(key string) (T, error)

Get 获取缓存项

func (*Cache[T]) Has

func (l *Cache[T]) Has(key string) (bool, error)

Has 检查键是否存在

func (*Cache[T]) Set

func (l *Cache[T]) Set(key string, val T, expireSeconds ...int) error

Set 设置缓存项

func (*Cache[T]) TTL

func (l *Cache[T]) TTL(key string) (int, error)

TTL 获取键的剩余生存时间

type MatchResultCache

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

MatchResultCache 专门用于MatchResult的缓存

func NewMatchResultCache

func NewMatchResultCache(size int) *MatchResultCache

NewMatchResultCache 创建MatchResult缓存

func (*MatchResultCache) Clear

func (c *MatchResultCache) Clear()

Clear 清空缓存

func (*MatchResultCache) Get

func (c *MatchResultCache) Get(key string) (*types.MatchResult, bool)

Get 获取匹配结果

func (*MatchResultCache) Put

func (c *MatchResultCache) Put(key string, result *types.MatchResult)

Put 存储匹配结果

Jump to

Keyboard shortcuts

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