store

package
v0.0.0-...-bf05b68 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryStore

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

MemoryStore 是主存储结构,包含多个分片

func NewMemoryStore

func NewMemoryStore(shardCount int, slotCount int, tickInterval time.Duration) *MemoryStore

NewMemoryStore 创建一个新的 MemoryStore

func (*MemoryStore) Close

func (ms *MemoryStore) Close()

Close 停止时间轮并清理资源

func (*MemoryStore) Delete

func (ms *MemoryStore) Delete(key string)

Delete 删除键

func (*MemoryStore) Get

func (ms *MemoryStore) Get(key string, clear bool) (any, int64, bool)

Get 获取键值对,并检查是否过期

func (*MemoryStore) IsExpired

func (ms *MemoryStore) IsExpired(key string) bool

IsExpired 检查指定键是否已过期

func (*MemoryStore) Set

func (ms *MemoryStore) Set(key string, value any, ttl time.Duration)

Set 设置键值对,并处理过期时间

func (*MemoryStore) Stats

func (ms *MemoryStore) Stats() map[string]any

Stats 返回当前统计信息

type TimeWheel

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

TimeWheel 是时间轮的核心结构

func (*TimeWheel) Add

func (tw *TimeWheel) Add(key string, expireAt time.Time)

Add 键加入到时间轮中

func (*TimeWheel) Remove

func (tw *TimeWheel) Remove(key string)

Remove 移除键

func (*TimeWheel) Start

func (tw *TimeWheel) Start()

Start 启动时间轮

func (*TimeWheel) Stop

func (tw *TimeWheel) Stop()

Stop 停止时间轮

Jump to

Keyboard shortcuts

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