model

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRouteWasNotFound added in v1.0.1

func IsRouteWasNotFound(err error) bool

func MatchRule added in v0.9.3

func MatchRule(cfg *config.Cache, path []byte) *config.Rule

func MatchRuleStr added in v0.9.3

func MatchRuleStr(cfg *config.Cache, path string) *config.Rule

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 EntryFromBytes(data []byte, cfg *config.Cache, backend repository.Backender) (*Entry, error)

func NewEntryFastHttp added in v0.9.3

func NewEntryFastHttp(cfg *config.Cache, r *fasthttp.RequestCtx) (*Entry, error)

NewEntryFastHttp accepts path, query and request headers as bytes slices.

func NewEntryFromField added in v0.9.3

func NewEntryFromField(
	key uint64,
	shard uint64,
	fingerprint [16]byte,
	payload []byte,
	rule *config.Rule,
	revalidator Revalidator,
	isCompressed int64,
	updatedAt int64,
) *Entry

func NewEntryManual added in v0.9.3

func NewEntryManual(cfg *config.Cache, path, query []byte, headers *[][2][]byte, revalidator Revalidator) (*Entry, error)

func NewEntryNetHttp added in v0.9.3

func NewEntryNetHttp(rule *config.Rule, r *http.Request) *Entry

NewEntryNetHttp accepts path, query and request headers as bytes slices.

func (*Entry) DumpBuffer added in v1.0.1

func (e *Entry) DumpBuffer(r *fasthttp.RequestCtx)

func (*Entry) DumpPayload added in v0.9.3

func (e *Entry) DumpPayload()

func (*Entry) Fingerprint added in v0.9.3

func (e *Entry) Fingerprint() [16]byte

func (*Entry) GetFilteredAndSortedKeyHeadersNetHttp added in v0.9.3

func (e *Entry) GetFilteredAndSortedKeyHeadersNetHttp(r *http.Request) (kvPairs *[][2][]byte, releaseFn func(*[][2][]byte))

func (*Entry) GetFilteredAndSortedKeyQueriesNetHttp added in v0.9.3

func (e *Entry) GetFilteredAndSortedKeyQueriesNetHttp(r *http.Request) (kvPairs *[][2][]byte, releaseFn func(*[][2][]byte))

func (*Entry) Init added in v0.9.3

func (e *Entry) Init() *Entry

func (*Entry) IsCompressed added in v0.9.3

func (e *Entry) IsCompressed() bool

func (*Entry) IsSameEntry added in v0.9.5

func (e *Entry) IsSameEntry(another *Entry) bool

func (*Entry) IsSameFingerprint added in v0.9.3

func (e *Entry) IsSameFingerprint(another [16]byte) bool

func (*Entry) IsSamePayload added in v1.0.1

func (e *Entry) IsSamePayload(another *Entry) bool

func (*Entry) LruListElement added in v0.9.3

func (e *Entry) LruListElement() *list.Element[*Entry]

LruListElement returns the LRU list element pointer (for LRU cache management).

func (*Entry) MapKey added in v0.9.3

func (e *Entry) MapKey() uint64

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(q, h *[][2][]byte),
	err error,
)

Payload decompresses the entire payload and unpacks it into fields.

func (*Entry) PayloadBytes added in v0.9.3

func (e *Entry) PayloadBytes() []byte

func (*Entry) Revalidate added in v0.9.3

func (e *Entry) Revalidate() error

Revalidate calls the revalidator closure to fetch fresh data and updates the timestamp.

func (*Entry) Rule added in v0.9.3

func (e *Entry) Rule() *config.Rule

func (*Entry) SetLruListElement added in v0.9.3

func (e *Entry) SetLruListElement(el *list.Element[*Entry])

SetLruListElement sets the LRU list element pointer.

func (*Entry) SetMapKey added in v0.9.3

func (e *Entry) SetMapKey(key uint64) *Entry

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) *Entry

func (*Entry) ShardKey added in v0.9.3

func (e *Entry) ShardKey() uint64

func (*Entry) ShouldBeRefreshed added in v0.9.3

func (e *Entry) ShouldBeRefreshed(cfg *config.Cache) bool

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.

func (*Entry) SwapPayloads added in v1.0.1

func (e *Entry) SwapPayloads(another *Entry)

func (*Entry) ToBytes added in v0.9.3

func (e *Entry) ToBytes() (data []byte, releaseFn func())

func (*Entry) TouchUpdatedAt added in v1.0.1

func (e *Entry) TouchUpdatedAt()

func (*Entry) UpdateAt added in v0.9.7

func (e *Entry) UpdateAt() int64

func (*Entry) Weight added in v0.9.3

func (e *Entry) Weight() int64

type Releaser added in v0.9.3

type Releaser func(queryHeaders *[][2][]byte, responseHeaders *[][2][]byte)

type Revalidator added in v0.9.3

type Revalidator func(rule *config.Rule, path []byte, query []byte, queryHeaders *[][2][]byte) (
	status int, headers *[][2][]byte, body []byte, releaseFn func(), err error,
)

Jump to

Keyboard shortcuts

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