storage

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKeyNotFound 键不存在错误
	ErrKeyNotFound = errors.New("key not found")
	// ErrKeyExpired 键已过期错误
	ErrKeyExpired = errors.New("key expired")
)

Functions

func NewStorage

func NewStorage() adapter.Storage

NewStorage 创建内存存储

func NewStorageWithCleanupInterval

func NewStorageWithCleanupInterval(interval time.Duration) adapter.Storage

NewStorageWithCleanupInterval 创建内存存储

Types

type Storage

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

Storage 内存存储实现

func (*Storage) Clear

func (s *Storage) Clear() error

Clear 清空所有数据

func (*Storage) Close

func (s *Storage) Close() error

Close 关闭存储,停止清理协程

func (*Storage) Delete

func (s *Storage) Delete(keys ...string) error

Delete 删除键

func (*Storage) Exists

func (s *Storage) Exists(key string) bool

Exists 检查键是否存在

func (*Storage) Expire

func (s *Storage) Expire(key string, expiration time.Duration) error

Expire 设置键的过期时间

func (*Storage) Get

func (s *Storage) Get(key string) (any, error)

Get 获取值

func (*Storage) Keys

func (s *Storage) Keys(pattern string) ([]string, error)

Keys 获取匹配模式的所有键

func (*Storage) Ping

func (s *Storage) Ping() error

Ping 检查存储可用性

func (*Storage) Set

func (s *Storage) Set(key string, value any, expiration time.Duration) error

Set 设置键值对

func (*Storage) TTL

func (s *Storage) TTL(key string) (time.Duration, error)

TTL 获取键的剩余生存时间

Jump to

Keyboard shortcuts

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