Help us shape the future of Go! Take the 2026 Go Developer Survey

redisshim

package
v0.32.21 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package redisshim 单机内存模式下 go-redis 命令面的等价实现(memkv.Store 的 redis 兼容垫片):redis.host 为空时 anonymous/presign 等域的 NewService 以此 兜底,取件码映射/直传会话等短 TTL 数据存进程内——不跨进程共享、重启即失, DB 仍是唯一真相源。容量/清扫参数用 memkv 包默认值(上限+周期清扫,对齐 lockout 内存兜底先例)。

命令结果用 go-redis 的 New*Result 构造器包装,redis.Nil 表不存在—— 消费域既有的 redis.Nil 判断两种模式通用,无分叉。

独立成子包是把 redis 客户端依赖隔离在 memkv 主包之外(本包依赖 go-redis)。 历史:anonymous/presign 曾各持一份几乎相同的 memoryKV(且 SetArgs 只在 anonymous 侧实现),2026-10-10 合并至此,命令面取两侧超集。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KV

type KV struct {
	Store *memkv.Store
}

KV memkv.Store 的 go-redis 命令面包装。Store 字段导出,供消费域测试 直接断言底层键值(如负缓存标记/映射回填)。

func New

func New() KV

New 构造独立实例(每个消费域自持一份,不共享表)。

func (KV) Del

func (m KV) Del(_ context.Context, keys ...string) *redis.IntCmd

func (KV) Get

func (m KV) Get(_ context.Context, key string) *redis.StringCmd

func (KV) Set

func (m KV) Set(_ context.Context, key string, value any, expiration time.Duration) *redis.StatusCmd

func (KV) SetArgs

func (m KV) SetArgs(_ context.Context, key string, value any, a redis.SetArgs) *redis.StatusCmd

SetArgs 消费面仅用 Mode:"NX"+TTL(GenerateCode 唯一性),其余选项不支持(fail-loud)。

Jump to

Keyboard shortcuts

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