NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
neforce::http::response_cache类 参考

HTTP响应缓存 更多...

#include <http_cache.hpp>

Public 成员函数

optional< cached_responseget (const string &key)
 获取缓存的响应
void put (const string &key, const http_response &response, seconds max_age=-1_s)
 存入缓存
void remove (const string &key)
 删除缓存条目
void cleanup ()
 清理过期条目
void clear ()
 清空所有缓存
size_t size () const
 缓存条目数

静态 Public 成员函数

static string generate_etag (string_view body)
 生成ETag值
static string build_key (const http_method &method, string_view url)
 构建缓存键

Public 属性

seconds default_max_age {60}
 默认缓存时间
size_t max_entries {10000}
 最大缓存条目数
byte_size max_body_size {1_MB}
 最大缓存响应体大小

详细描述

HTTP响应缓存

基于URL的响应缓存,支持ETag和Cache-Control。 线程安全,支持LRU淘汰。

在文件 http_cache.hpp40 行定义.

成员函数说明

◆ get()

optional< cached_response > neforce::http::response_cache::get ( const string & key)

获取缓存的响应

参数
key缓存键(通常为 method+url)
返回
缓存的响应,不存在返回none

◆ put()

void neforce::http::response_cache::put ( const string & key,
const http_response & response,
seconds max_age = -1_s )

存入缓存

参数
key缓存键
response响应对象

该类的文档由以下文件生成: