ttlcache

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCache = NewCache()

Functions

func HashKey

func HashKey(key []byte) uint64

Types

type Cache

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

TTL缓存 最大的缓存时间为30 * 86400 Piece数据结构:

    Piece1          |  Piece2 | Piece3 | ...
[ Item1, Item2, ... |   ...

KeyMap列表数据结构 { timestamp1 => [key1, key2, ...] }, ...

func NewCache

func NewCache(opt ...OptionInterface) *Cache

func (*Cache) Count

func (this *Cache) Count() (count int)

func (*Cache) Delete

func (this *Cache) Delete(key string)

func (*Cache) Destroy

func (this *Cache) Destroy()

func (*Cache) GC

func (this *Cache) GC()

func (*Cache) IncreaseInt64

func (this *Cache) IncreaseInt64(key string, delta int64, expiredAt int64) int64

func (*Cache) Read

func (this *Cache) Read(key string) (item *Item)

func (*Cache) Write

func (this *Cache) Write(key string, value interface{}, expiredAt int64)

type Item

type Item struct {
	Value interface{}
	// contains filtered or unexported fields
}

type MaxItemsOption

type MaxItemsOption struct {
	Count int
}

func NewMaxItemsOption

func NewMaxItemsOption(count int) *MaxItemsOption

type OptionInterface

type OptionInterface interface {
}

type Piece

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

func NewPiece

func NewPiece(maxItems int) *Piece

func (*Piece) Add

func (this *Piece) Add(key uint64, item *Item)

func (*Piece) Count

func (this *Piece) Count() (count int)

func (*Piece) Delete

func (this *Piece) Delete(key uint64)

func (*Piece) Destroy

func (this *Piece) Destroy()

func (*Piece) GC

func (this *Piece) GC()

func (*Piece) IncreaseInt64

func (this *Piece) IncreaseInt64(key uint64, delta int64, expiredAt int64) (result int64)

func (*Piece) Read

func (this *Piece) Read(key uint64) (item *Item)

type PiecesOption

type PiecesOption struct {
	Count int
}

func NewPiecesOption

func NewPiecesOption(count int) *PiecesOption

Jump to

Keyboard shortcuts

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