lrucache

package
Version: v0.0.0-...-3ccd4c2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LRUCache

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

LRUCache 进程内的LRU缓存。只存储最近使用的。 基于github.com/wencan/xsync/LRUMap,按批次(区块)清理最近不用的数据。 实现了github.com/wencan/fastrest/restcache的Storage接口和MStorage接口。

func NewLRUCache

func NewLRUCache(chunkCapacity int, chunkNum int) *LRUCache

NewLRUCache 创建lru缓存。chunkCapacity、chunkNum是github.com/wencan/xsync/LRUMap的区块参数。

func (*LRUCache) Get

func (lru *LRUCache) Get(ctx context.Context, key string, valuePtr interface{}) (found bool, err error)

Get 实现github.com/wencan/fastrest/restcache的Storage接口。

func (*LRUCache) MGet

func (lru *LRUCache) MGet(ctx context.Context, keys []string, destSlicePtr interface{}) (missIndexes []int, err error)

MGet 实现github.com/wencan/fastrest/restcache的MStorage接口。

func (*LRUCache) MSet

func (lru *LRUCache) MSet(ctx context.Context, keys []string, destSlice interface{}, ttl time.Duration) error

MSet 实现github.com/wencan/fastrest/restcache的MStorage接口。

func (*LRUCache) Set

func (lru *LRUCache) Set(ctx context.Context, key string, value interface{}, TTL time.Duration) error

Set 实现github.com/wencan/fastrest/restcache的Storage接口。

Source Files

Jump to

Keyboard shortcuts

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