teamemory

package
v0.1.72 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: MIT Imports: 10 Imported by: 0

README

Memory Grid

Cache items in memory, using partitions and LRU.

Documentation

Index

Constants

View Source
const (
	ItemInt64     = 1
	ItemBytes     = 2
	ItemInterface = 3
)

Variables

This section is empty.

Functions

func HashKey

func HashKey(key []byte) uint64

Types

type Cell

type Cell struct {
	LimitSize int64
	// contains filtered or unexported fields
}

func NewCell

func NewCell() *Cell

func (*Cell) Delete

func (this *Cell) Delete(hashKey uint64)

func (*Cell) Increase64

func (this *Cell) Increase64(key []byte, expireAt int64, hashKey uint64, delta int64) (result int64)

func (*Cell) Read

func (this *Cell) Read(hashKey uint64) *Item

func (*Cell) Recycle

func (this *Cell) Recycle()

func (*Cell) Reset

func (this *Cell) Reset()

func (*Cell) Stat

func (this *Cell) Stat() *CellStat

func (*Cell) Trim

func (this *Cell) Trim()

trim NOT ACTIVE items should called in locker context

func (*Cell) Write

func (this *Cell) Write(hashKey uint64, item *Item)

type CellStat

type CellStat struct {
	TotalBytes int64
	CountItems int
}

type CompressOpt

type CompressOpt struct {
	Level int
}

func NewCompressOpt

func NewCompressOpt(level int) *CompressOpt

type Grid

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

Memory Cache Grid

| Grid | | cell1, cell2, ..., cell1024 | | item1, item2, ..., item1000000 |

func NewGrid

func NewGrid(countCells int, opt ...interface{}) *Grid

func (*Grid) Delete

func (this *Grid) Delete(key []byte)

func (*Grid) Destroy

func (this *Grid) Destroy()

func (*Grid) IncreaseInt64

func (this *Grid) IncreaseInt64(key []byte, delta int64, lifeSeconds int64) (result int64)

func (*Grid) Read

func (this *Grid) Read(key []byte) *Item

func (*Grid) Reset

func (this *Grid) Reset()

func (*Grid) Stat

func (this *Grid) Stat() *Stat

func (*Grid) WriteBytes

func (this *Grid) WriteBytes(key []byte, value []byte, lifeSeconds int64)

func (*Grid) WriteInt64

func (this *Grid) WriteInt64(key []byte, value int64, lifeSeconds int64)

func (*Grid) WriteInterface

func (this *Grid) WriteInterface(key []byte, value interface{}, lifeSeconds int64)

func (*Grid) WriteItem

func (this *Grid) WriteItem(item *Item)

func (*Grid) WriteString

func (this *Grid) WriteString(key []byte, value string, lifeSeconds int64)

type Item

type Item struct {
	Key            []byte
	ExpireAt       int64
	Type           ItemType
	ValueInt64     int64
	ValueBytes     []byte
	ValueInterface interface{}
	IsCompressed   bool

	// linked list
	Prev *Item
	Next *Item
}

func NewItem

func NewItem(key []byte, dataType ItemType) *Item

func (*Item) Bytes

func (this *Item) Bytes() []byte

func (*Item) HashKey

func (this *Item) HashKey() uint64

func (*Item) IncreaseInt64

func (this *Item) IncreaseInt64(delta int64)

func (*Item) Size

func (this *Item) Size() int64

func (*Item) String

func (this *Item) String() string

type ItemType

type ItemType = int

type LimitSizeOpt

type LimitSizeOpt struct {
	Size int64
}

func NewLimitSizeOpt

func NewLimitSizeOpt(size int64) *LimitSizeOpt

type List

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

func NewList

func NewList() *List

func (*List) Add

func (this *List) Add(item *Item)

func (*List) Len

func (this *List) Len() int

func (*List) Range

func (this *List) Range(f func(item *Item) (goNext bool))

func (*List) Remove

func (this *List) Remove(item *Item)

func (*List) Reset

func (this *List) Reset()

type RecycleIntervalOpt

type RecycleIntervalOpt struct {
	Interval int
}

func NewRecycleIntervalOpt

func NewRecycleIntervalOpt(interval int) *RecycleIntervalOpt

type Stat

type Stat struct {
	TotalBytes int64
	CountItems int
}

Jump to

Keyboard shortcuts

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