cache

package
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cache 提供了基于内存的HTTP响应缓存中间件

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func URLAndHeaderKeyGenerator

func URLAndHeaderKeyGenerator(headers ...string) func(*mist.Context) string

URLAndHeaderKeyGenerator 返回一个基于URL和指定头的键生成器函数

func URLKeyGenerator

func URLKeyGenerator() func(*mist.Context) string

URLKeyGenerator 返回一个基于请求URL的键生成器函数

Types

type ResponseCache

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

ResponseCache 用于缓存HTTP响应数据

func New

func New(size int, ttl time.Duration) (*ResponseCache, error)

New 创建一个新的ResponseCache实例 size: 缓存项数量 ttl: 缓存项过期时间

func (*ResponseCache) Clear

func (rc *ResponseCache) Clear()

Clear 清空缓存

func (*ResponseCache) Middleware

func (rc *ResponseCache) Middleware(keyFunc func(*mist.Context) string) mist.Middleware

Middleware 创建一个缓存中间件,使用给定的键生成器函数 keyFunc 函数用于从请求上下文生成缓存键

Jump to

Keyboard shortcuts

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