cacheflush

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cacheflush 提供对 C 端站点 API(web-api-go)缓存刷新接口的极简 HTTP 客户端。

job 仓库不能反向依赖 web-admin,故独立实现; 请求/响应结构与 web-admin/pkg/webapi.RefreshCacheRequest 保持一致, 仅使用 job 侧需要的 site/site_id/page 三个字段(整类前缀刷新,不带精确 ID)。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Refresh

func Refresh(ctx context.Context, cfg Config, req RefreshRequest) (int64, error)

Refresh 调用前端 API 的缓存刷新接口,返回删除的键数量

Types

type Config

type Config struct {
	// BaseURL 服务地址,如 http://127.0.0.1:3210
	BaseURL string `json:",default=http://127.0.0.1:3210"`
	// RefreshToken 缓存刷新接口共享令牌(X-Refresh-Token 请求头),与 web-api-go
	// security.cache_refresh_token 同值;未启用令牌时留空
	RefreshToken string `json:",optional"`
}

Config 前端 API 服务配置

type RefreshRequest

type RefreshRequest struct {
	Site   string `json:"site,omitempty"`    // 站点模块名:coupon/app/site/blog
	SiteID uint64 `json:"site_id,omitempty"` // 站点实例 ID,0 表示跨实例整类
	Page   string `json:"page,omitempty"`    // 页面/资源类型(缓存 key 第一段,须搭配 site)
}

RefreshRequest 缓存刷新请求(范围逐级收窄;job 侧只用整类模式:site+site_id+page)

Jump to

Keyboard shortcuts

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