ttlcache

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SharedInt64Cache = NewBigCache[int64]()
View Source
var SharedManager = NewManager()

Functions

func HashKeyBytes added in v1.3.5

func HashKeyBytes(key []byte) uint64

func HashKeyString added in v1.3.5

func HashKeyString(key string) uint64

Types

type Cache

type Cache[T any] struct {
	// contains filtered or unexported fields
}

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

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

func NewBigCache added in v1.1.0

func NewBigCache[T any]() *Cache[T]

func NewCache

func NewCache[T any](opt ...OptionInterface) *Cache[T]

func (*Cache[T]) Clean

func (this *Cache[T]) Clean()

func (*Cache[T]) Count

func (this *Cache[T]) Count() (count int)

func (*Cache[T]) Delete

func (this *Cache[T]) Delete(key string)

func (*Cache[T]) Destroy

func (this *Cache[T]) Destroy()

func (*Cache[T]) GC

func (this *Cache[T]) GC()

func (*Cache[T]) IncreaseInt64

func (this *Cache[T]) IncreaseInt64(key string, delta T, expiredAt int64, extend bool) T

func (*Cache[T]) Read

func (this *Cache[T]) Read(key string) (item *Item[T])

func (*Cache[T]) Write

func (this *Cache[T]) Write(key string, value T, expiredAt int64) (ok bool)

type GCAble added in v1.2.10

type GCAble interface {
	GC()
}

type Item

type Item[T any] struct {
	Value T
	// 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 GCAble)

func (*Manager) Count

func (this *Manager) Count() int

func (*Manager) Remove

func (this *Manager) Remove(cache GCAble)

type MaxItemsOption

type MaxItemsOption struct {
	Count int
}

func NewMaxItemsOption

func NewMaxItemsOption(count int) *MaxItemsOption

type OptionInterface

type OptionInterface interface {
}

type Piece

type Piece[T any] struct {
	// contains filtered or unexported fields
}

func NewPiece

func NewPiece[T any](maxItems int) *Piece[T]

func (*Piece[T]) Add

func (this *Piece[T]) Add(key uint64, item *Item[T]) (ok bool)

func (*Piece[T]) Clean

func (this *Piece[T]) Clean()

func (*Piece[T]) Count

func (this *Piece[T]) Count() (count int)

func (*Piece[T]) Delete

func (this *Piece[T]) Delete(key uint64)

func (*Piece[T]) Destroy

func (this *Piece[T]) Destroy()

func (*Piece[T]) GC

func (this *Piece[T]) GC()

func (*Piece[T]) IncreaseInt64

func (this *Piece[T]) IncreaseInt64(key uint64, delta T, expiredAt int64, extend bool) (result T)

func (*Piece[T]) Read

func (this *Piece[T]) Read(key uint64) (item *Item[T])

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