Documentation
¶
Index ¶
- Variables
- func MatchRule(cfg *config.Cache, path []byte) *config.Rule
- func MatchRuleStr(cfg *config.Cache, path string) *config.Rule
- func NewEntryFastHttp(cfg *config.Cache, r *fasthttp.RequestCtx) (*Entry, Releaser, error)
- func NewEntryManual(cfg *config.Cache, path, query []byte, headers [][2][]byte, ...) (*Entry, Releaser, error)
- func NewEntryNetHttp(cfg *config.Cache, r *http.Request) (*Entry, Releaser, error)
- type Entry
- func (e *Entry) DumpPayload()
- func (e *Entry) Fingerprint() [16]byte
- func (e *Entry) GetFilteredAndSortedKeyHeadersNetHttp(r *http.Request) (kvPairs [][2][]byte, releaseFn func())
- func (e *Entry) GetFilteredAndSortedKeyQueriesNetHttp(r *http.Request) (kvPairs [][2][]byte, releaseFn func())
- func (e *Entry) Init() *Entry
- func (e *Entry) IsCompressed() bool
- func (e *Entry) IsSame(another *Entry) bool
- func (e *Entry) IsSameFingerprint(another [16]byte) bool
- func (e *Entry) LruListElement() *list.Element[*Entry]
- func (e *Entry) MapKey() uint64
- func (e *Entry) Payload() (path []byte, query []byte, queryHeaders [][2][]byte, ...)
- func (e *Entry) PayloadBytes() []byte
- func (e *Entry) Release()
- func (e *Entry) Revalidate() error
- func (e *Entry) Rule() *config.Rule
- func (e *Entry) SetLruListElement(el *list.Element[*Entry])
- func (e *Entry) SetMapKey(key uint64) *Entry
- func (e *Entry) SetPayload(path, query []byte, queryHeaders [][2][]byte, headers [][2][]byte, body []byte, ...)
- func (e *Entry) SetRevalidator(revalidator Revalidator)
- func (e *Entry) ShardKey() uint64
- func (e *Entry) ShouldBeRefreshed(cfg *config.Cache) bool
- func (e *Entry) ToBytes() (data []byte, releaseFn func())
- func (e *Entry) Weight() int64
- func (e *Entry) WillUpdateAt() int64
- type Releaser
- type Revalidator
Constants ¶
This section is empty.
Variables ¶
var EntriesPool = sync.Pool{ New: func() interface{} { return new(Entry).Init() }, }
Functions ¶
func NewEntryFastHttp ¶ added in v0.9.3
NewEntryFastHttp accepts path, query and request headers as bytes slices.
func NewEntryManual ¶ added in v0.9.3
Types ¶
type Entry ¶ added in v0.9.3
type Entry struct {
// contains filtered or unexported fields
}
Entry is the packed request+response payload
func EntryFromBytes ¶ added in v0.9.3
func NewEntryFromField ¶ added in v0.9.3
func (*Entry) DumpPayload ¶ added in v0.9.3
func (e *Entry) DumpPayload()
func (*Entry) Fingerprint ¶ added in v0.9.3
func (*Entry) GetFilteredAndSortedKeyHeadersNetHttp ¶ added in v0.9.3
func (*Entry) GetFilteredAndSortedKeyQueriesNetHttp ¶ added in v0.9.3
func (*Entry) IsCompressed ¶ added in v0.9.3
func (*Entry) IsSameFingerprint ¶ added in v0.9.3
func (*Entry) LruListElement ¶ added in v0.9.3
LruListElement returns the LRU list element pointer (for LRU cache management).
func (*Entry) Payload ¶ added in v0.9.3
func (e *Entry) Payload() ( path []byte, query []byte, queryHeaders [][2][]byte, responseHeaders [][2][]byte, body []byte, status int, releaseFn func(), err error, )
Payload decompresses the entire payload and unpacks it into fields.
func (*Entry) PayloadBytes ¶ added in v0.9.3
func (*Entry) Release ¶ added in v0.9.3
func (e *Entry) Release()
Release used as a Releaser and returns buffers back to pools.
func (*Entry) Revalidate ¶ added in v0.9.3
Revalidate calls the revalidator closure to fetch fresh data and updates the timestamp.
func (*Entry) SetLruListElement ¶ added in v0.9.3
SetLruListElement sets the LRU list element pointer.
func (*Entry) SetMapKey ¶ added in v0.9.3
SetMapKey is really dangerous - must be used exclusively in tests.
func (*Entry) SetPayload ¶ added in v0.9.3
func (e *Entry) SetPayload( path, query []byte, queryHeaders [][2][]byte, headers [][2][]byte, body []byte, status int, )
SetPayload packs and gzip-compresses the entire payload: Path, Query, QueryHeaders, StatusCode, ResponseHeaders, Body.
func (*Entry) SetRevalidator ¶ added in v0.9.3
func (e *Entry) SetRevalidator(revalidator Revalidator)
func (*Entry) ShouldBeRefreshed ¶ added in v0.9.3
ShouldBeRefreshed 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.