ttlcache

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2022 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SharedCache = NewCache()
View Source
var SharedManager = NewManager()

Functions

func HashKey

func HashKey(key []byte) uint64

Types

type Cache

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

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

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

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

func NewCache

func NewCache(opt ...OptionInterface) *Cache

func (*Cache) Clean

func (this *Cache) Clean()

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, extend bool) 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) (ok bool)

type Item

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

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) Add

func (this *Manager) Add(cache *Cache)

func (*Manager) Count

func (this *Manager) Count() int

func (*Manager) Remove

func (this *Manager) Remove(cache *Cache)

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) (ok bool)

func (*Piece) Clean

func (this *Piece) Clean()

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, extend bool) (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