Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNilValue ¶ added in v0.10.1
func IsNilValue(data interface{}) bool
IsNilValue reports whether data is a nil pointer or a nil interface, i.e. a value that must not be cached.
gob.Encoder.Encode *panics* on a top-level nil pointer ("gob: cannot encode nil pointer of type ...") instead of returning an error, so a repository method that legitimately answers "no such thing" with (nil, nil) — an AWS lookup that matched nothing — would take the whole process down as soon as the generated cached wrapper stored its result. Writes of such values are skipped: nothing is stored and the next call refetches.
Handler implementations serializing with gob must apply the same check.
func Key ¶ added in v0.5.0
Key builds a deterministic cache key from a method name and its parameters.
Parameters are rendered by value: pointers are dereferenced, map entries sorted and unexported fields included, so equal arguments always produce the same key and different arguments never share one. Formatting parameters with %v instead would embed pointer addresses for every nested pointer field — which is how AWS SDK input structs are built — yielding a key that changes on every call and can collide once the allocator reuses an address.
The method name is kept as a readable prefix; the parameters are folded into an FNV-64a suffix. The result is safe to use as a file name.
Types ¶
type DataCache ¶
type DataCache struct {
// contains filtered or unexported fields
}
func NewDataCache ¶
func NewDataCache() *DataCache
func (*DataCache) WithHandlers ¶
func (c *DataCache) WithHandlers(handlers ...HandlerInterface) *DataCache