Documentation
¶
Index ¶
- type Data
- type Request
- type Response
- func (r *Response) Body() []byte
- func (r *Response) CASRefCount(old, new int64) bool
- func (r *Response) Data() *Data
- func (r *Response) DecRefCount() int64
- func (r *Response) Headers() http.Header
- func (r *Response) IncRefCount() int64
- func (r *Response) IsDoomed() bool
- func (r *Response) Key() uint64
- func (r *Response) LruListElement() *list.Element[*Response]
- func (r *Response) MarkAsDoomed() bool
- func (r *Response) NativeRevalidateInterval() int64
- func (r *Response) NativeRevalidatedAt() int64
- func (r *Response) RefCount() int64
- func (r *Response) Release() bool
- func (r *Response) Request() *Request
- func (r *Response) Revalidate(ctx context.Context) error
- func (r *Response) RevalidatedAt() time.Time
- func (r *Response) SetLruListElement(el *list.Element[*Response])
- func (r *Response) ShardKey() uint64
- func (r *Response) ShardListElement() any
- func (r *Response) ShouldRefresh() bool
- func (r *Response) Size() uintptr
- func (r *Response) StoreRefCount(new int64)
- func (r *Response) StoreWheelListElement(elem *list.Element[timemodel.Spoke])
- func (r *Response) ToQuery() []byte
- func (r *Response) WheelListElement() *list.Element[timemodel.Spoke]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Data ¶ added in v0.3.0
type Data struct {
// contains filtered or unexported fields
}
Data is the actual payload (status, headers, body) stored in the cache.
func NewData ¶ added in v0.3.0
func NewData(statusCode int, headers http.Header, body []byte, releaseBody synced.FreeResourceFunc) *Data
NewData creates a new Data object, compressing body with gzip if large enough. Uses memory pools for buffer and writer to minimize allocations.
func (*Data) Release ¶ added in v0.7.0
func (d *Data) Release()
Release calls releaseFn and returns the Data to the pool.
func (*Data) StatusCode ¶ added in v0.3.0
StatusCode returns the HTTP status code.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request holds normalized, deduplicated, hashed and uniquely queryable representation of a cache request.
func NewManualRequest ¶ added in v0.3.1
NewManualRequest creates a Request with explicit parameters, bypassing fasthttp.
func NewRequest ¶
NewRequest builds a Request from fasthttp.Args, with strict interning and pooling.
func (*Request) GetLanguage ¶
func (*Request) GetProject ¶
Getters for all important fields.
func (*Request) Release ¶ added in v0.7.0
func (r *Request) Release()
Release releases and resets the request (and any underlying buffer/tag slices) for reuse.
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response is the main cache object, holding the request, payload, metadata, and list pointers.
func NewResponse ¶
func NewResponse( data *Data, req *Request, cfg *config.Config, revalidator func(ctx context.Context) (data *Data, err error), ) (*Response, error)
NewResponse constructs a new Response using memory pools and sets up all fields.
func (*Response) CASRefCount ¶ added in v0.7.0
CASRefCount performs a CAS on the refcount.
func (*Response) DecRefCount ¶ added in v0.7.0
DecRefCount decrements the refcount.
func (*Response) IncRefCount ¶ added in v0.7.0
IncRefCount increments the refcount.
func (*Response) IsDoomed ¶ added in v0.7.0
IsDoomed returns true if this object is scheduled for deletion.
func (*Response) LruListElement ¶ added in v0.7.0
LruListElement returns the LRU list element pointer (for LRU cache management).
func (*Response) MarkAsDoomed ¶ added in v0.7.0
MarkAsDoomed marks the response as scheduled for delete, only if not already doomed.
func (*Response) NativeRevalidateInterval ¶ added in v0.7.0
NativeRevalidateInterval returns the revalidation interval (as int64).
func (*Response) NativeRevalidatedAt ¶ added in v0.7.0
NativeRevalidatedAt returns the last revalidation time (as int64).
func (*Response) Release ¶ added in v0.7.0
Release releases the associated Data and Request, resets the Response, and returns it to the pool.
func (*Response) Revalidate ¶
Revalidate calls the revalidator closure to fetch fresh data and updates the timestamp.
func (*Response) RevalidatedAt ¶ added in v0.7.0
RevalidatedAt returns the last revalidation time (as time.Time).
func (*Response) SetLruListElement ¶ added in v0.7.0
SetLruListElement sets the LRU list element pointer.
func (*Response) ShardKey ¶ added in v0.7.0
ShardKey returns the shard key of the associated request.
func (*Response) ShardListElement ¶ added in v0.7.0
ShardListElement returns the LRU list element (for cache eviction).
func (*Response) ShouldRefresh ¶ added in v0.7.0
ShouldRefresh implements probabilistic refresh logic ("beta" algorithm). Returns true if the entry is stale and, with a probability proportional to its staleness, should be refreshed now.
func (*Response) Size ¶
Size estimates the in-memory size of this response (including dynamic fields).
func (*Response) StoreRefCount ¶ added in v0.7.0
StoreRefCount stores a new refcount value directly.
func (*Response) StoreWheelListElement ¶ added in v1.1.0
StoreWheelListElement sets the wheel list element pointer.