cache

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache 结构体 Cache struct

func NewCache

func NewCache() *Cache

NewCache 函数创建并返回一个新的 Cache 实例 The NewCache function creates and returns a new Cache instance

func (*Cache) Cleanup

func (c *Cache) Cleanup(fn func(value any))

Cleanup 方法遍历 Cache 中的所有键值对,并对每个值执行给定的函数,然后删除该键值对 The Cleanup method traverses all key-value pairs in Cache, performs the given function on each value, and then deletes the key-value pair

func (*Cache) Count

func (c *Cache) Count() int

Count 方法返回 Cache 中的键值对数量 The Count method returns the number of key-value pairs in Cache

func (*Cache) Delete

func (c *Cache) Delete(key string)

Delete 方法从 Cache 中删除给定的键 The Delete method deletes the given key from Cache

func (*Cache) Get

func (c *Cache) Get(key string) (value any, ok bool)

Get 方法根据给定的键从 Cache 中获取值 The Get method gets the value from Cache based on the given key

func (*Cache) Set

func (c *Cache) Set(key string, value any)

Set 方法将给定的键值对设置到 Cache 中 The Set method sets the given key-value pair to Cache

type Segment

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

Segment 结构体 Segment struct

func NewSegment

func NewSegment() *Segment

NewSegment 函数创建并返回一个新的 Segment 实例 The NewSegment function creates and returns a new Segment instance

func (*Segment) Cleanup

func (s *Segment) Cleanup(fn func(any))

Cleanup 方法遍历 storage 中的所有键值对,并对每个值执行给定的函数,然后删除该键值对 The Cleanup method traverses all key-value pairs in storage, performs the given function on each value, and then deletes the key-value pair

func (*Segment) Count

func (s *Segment) Count() int

Count 方法返回 storage 中的键值对数量 The Count method returns the number of key-value pairs in storage

func (*Segment) Delete

func (s *Segment) Delete(key string)

Delete 方法从 storage 中删除给定的键 The Delete method deletes the given key from storage

func (*Segment) Get

func (s *Segment) Get(key string) (any, bool)

Get 方法根据给定的键从 storage 中获取值 The Get method gets the value from storage based on the given key

func (*Segment) Set

func (s *Segment) Set(key string, value any)

Set 方法将给定的键值对设置到 storage 中 The Set method sets the given key-value pair to storage

Jump to

Keyboard shortcuts

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