mem

package
v0.0.0-...-0cb7091 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2021 License: BSD-3-Clause-Clear Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key struct {
	Mem string // 哪个池中
	KEY string // Key的名称
}

func (Key) Delete

func (k Key) Delete()

func (Key) Get

func (k Key) Get() (interface{}, bool)

func (Key) GetWithExpiration

func (k Key) GetWithExpiration() (interface{}, time.Time, bool)

func (Key) Replace

func (k Key) Replace(newVal interface{}, d ...time.Duration) error

func (Key) Set

func (k Key) Set(val interface{}, ttl ...time.Duration)

type Mem

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

 => 对象管理器

func AddMem

func AddMem(name string, onEvicted func(string, interface{})) *Mem

AddMem 添加指定缓存器 (数据过期时触发回调 onEvicted)

func GetMem

func GetMem(name string) *Mem

GetMem 获取指定缓存器

func (*Mem) Clear

func (m *Mem) Clear()

Mem.Clear Delete all items from the mem.

func (*Mem) Count

func (m *Mem) Count() int

Mem.Count Returns the number of items in the memory.

func (*Mem) Delete

func (m *Mem) Delete(k string)

Mem.Delete 移除对象

func (*Mem) DeleteExpired

func (m *Mem) DeleteExpired()

Mem.DeleteExpired 移除过期对象

func (*Mem) Get

func (m *Mem) Get(k string) (interface{}, bool)

Mem.Get 获取对象

func (*Mem) GetWithExpiration

func (m *Mem) GetWithExpiration(k string) (interface{}, time.Time, bool)

Mem.GetWithExpiration 获取对象连带结束时间

func (*Mem) Init

func (m *Mem) Init(onEvicted func(string, interface{})) *Mem

func (*Mem) Items

func (m *Mem) Items() map[string]Obj

Mem.Items Copies all unexpired items in the memory into a new map and returns it.

func (*Mem) Load

func (m *Mem) Load(r io.Reader) error

Mem.Load Add (Gob-serialized) memory items from an io.Reader.

func (*Mem) LoadFile

func (m *Mem) LoadFile(fname string) error

Mem.LoadFile Load and add memory items from the given filename.

func (*Mem) Replace

func (m *Mem) Replace(k string, x interface{}, d ...time.Duration) error

Mem.Replace 仅对象存在的时候才替换

func (*Mem) Save

func (m *Mem) Save(w io.Writer) (err error)

Mem.Save Write the mem's items (using Gob) to an io.Writer.

func (*Mem) SaveFile

func (m *Mem) SaveFile(fname string) error

Mem.SaveFile Save the mem's items to the given filename.

func (*Mem) Set

func (m *Mem) Set(k string, x interface{}, ttl ...time.Duration)

Mem.Set 设置对象

type Obj

type Obj struct {
	Object     interface{}
	Expiration int64
}

 => 存储对象

func (Obj) Expired

func (o Obj) Expired() bool

Jump to

Keyboard shortcuts

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