Documentation ¶
Index ¶
- Constants
- Variables
- type CachedResponse
- type Client
- func (c *Client) Cacheable(key []byte, ttl uint16)
- func (c *Client) ClearExpired(delay int)
- func (c *Client) Close() error
- func (c *Client) GetCachedList() []*CachedResponse
- func (c *Client) GetFetchingList() []*FetchingResponse
- func (c *Client) GetRequestStatus(key []byte) (status int, ch chan int)
- func (c *Client) GetResponse(key []byte) (resp *Response, err error)
- func (c *Client) GetStats() (stats *Stats)
- func (c *Client) HitForPass(key []byte, ttl uint16)
- func (c *Client) Init() error
- func (c *Client) Remove(key []byte) error
- func (c *Client) SaveResponse(key []byte, resp *Response) error
- func (c *Client) Size() int
- func (c *Client) UpdateRequestStatus(key []byte, status int, ttl uint16)
- type FetchingResponse
- type RequestStatus
- type Response
- type Stats
Constants ¶
View Source
const ( // Pass request status: pass Pass = iota + 1 // Fetching request status: fetching Fetching // Waiting request status: wating Waiting // HitForPass request status: hitForPass HitForPass // Cacheable request status: cacheable Cacheable )
View Source
const ( // CompressMinLength the min length to gzip CompressMinLength = 1024 // GzipEncoding gzip encoding GzipEncoding = "gzip" // BrEncoding br encoding BrEncoding = "br" )
Variables ¶
View Source
var ( // ErrBodyCotentNotFound 无数据 ErrBodyCotentNotFound = errors.New("content not found") )
View Source
var StatusDescArr = []string{
"",
"pass",
"fetching",
"waiting",
"hitForPass",
"cacheable",
}
StatusDescArr status desc
Functions ¶
This section is empty.
Types ¶
type CachedResponse ¶
type CachedResponse struct { Key string `json:"key"` TTL uint16 `json:"ttl"` CreatedAt uint32 `json:"createdAt"` }
CachedResponse 缓存的请求
type Client ¶
Client 缓存
func (*Client) GetCachedList ¶
func (c *Client) GetCachedList() []*CachedResponse
GetCachedList 获取缓存列表
func (*Client) GetFetchingList ¶
func (c *Client) GetFetchingList() []*FetchingResponse
GetFetchingList 获取fetching的列表
func (*Client) GetRequestStatus ¶
GetRequestStatus 获取key对应的请求status
func (*Client) GetResponse ¶
GetResponse 从缓存中获取Response
func (*Client) HitForPass ¶
HitForPass 设置为hit for pass
func (*Client) SaveResponse ¶
SaveResponse 保存response
type FetchingResponse ¶
FetchingResponse fetching中的请求
type RequestStatus ¶
type RequestStatus struct {
// contains filtered or unexported fields
}
RequestStatus 获取请求状态
type Response ¶
type Response struct { // 创建时间 CreatedAt uint32 `json:"createdAt"` // HTTP状态码 StatusCode uint16 `json:"statusCode"` // 缓存有效时间(最大65535) TTL uint16 `json:"ttl"` // HTTP响应头 Header http.Header `json:"header"` // HTTP响应数据 Body []byte `json:"body"` // HTTP响应数据(gzip) GzipBody []byte `json:"gzip"` // HTTP响应数据(br) BrBody []byte `json:"br"` // 压缩数据级别 CompressLevel int `json:"compressLevel"` // 最小压缩数据 CompressMinLength int `json:"compressMinLength"` }
Response 响应数据
Click to show internal directories.
Click to hide internal directories.