cache

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cache 定义缓存接口及其实现。

Cache 接口由 engine 层依赖(依赖倒置),运行时层注入 Redis 或 noop 实现。 value 用 []byte(proto 序列化的天然格式),TTL 用 time.Duration。

Package cache 的空实现。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Get 按 key 取缓存值,未命中返回 nil 和 false。
	Get(ctx context.Context, key string) ([]byte, bool, error)

	// Set 写入缓存,带 TTL。
	Set(ctx context.Context, key string, value []byte, ttl time.Duration) error

	// Delete 删除缓存 key。
	Delete(ctx context.Context, key string) error
}

Cache 是缓存接口。engine.Execute 通过它缓存 proto 序列化后的响应。

type Noop

type Noop struct{}

Noop 是 Cache 的空实现,永远未命中,不做任何存储。 地基阶段未接入 Redis 时用。

func (Noop) Delete

func (Noop) Delete(context.Context, string) error

Delete 不做任何事。

func (Noop) Get

func (Noop) Get(context.Context, string) ([]byte, bool, error)

Get 永远未命中。

func (Noop) Set

Set 不做任何事。

Directories

Path Synopsis
Package redis 实现 Cache 接口的 Redis 存储。
Package redis 实现 Cache 接口的 Redis 存储。

Jump to

Keyboard shortcuts

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