Documentation
¶
Overview ¶
Package codec encodes cache values for the backends that store bytes rather than live objects.
It exists to keep encoding and decoding keyed on the same thing. The compact encoding dispatches on a value's dynamic type, taking a direct path for strings, byte slices and numbers, while decoding dispatches on the static type of its destination. The two agree whenever the cached type is concrete, and disagree exactly when it is an interface: a string stored through a Cache[any] would be written as raw bytes and then read back into an *any, where the compact form is not valid JSON and decoding fails with "unexpected value type". The exported Marshal and Unmarshal route both directions through the static T, which removes the disagreement at its source.
The encoding is process-local and carries no compatibility promise: it is not JSON for scalars, and nothing persists across a restart.
DropUnreadable is the one answer to an entry that still fails to decode, shared by every backend that stores bytes, the Redis one included.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DropUnreadable ¶
DropUnreadable answers a Get whose stored bytes cannot be decoded as the caller's type, the same way for every backend that stores bytes: the entry is logged at Warn with its key and the decode error, removed through drop so the next read does not trip over it again, and reported as a miss with types.ErrEntryNotFound, so the caller falls back to its source of truth and rewrites the entry as it would for a key never stored. A drop that fails is logged as well; the read is still a miss and the entry is retried on the next read.
Types ¶
This section is empty.