Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ItemPool = sync.Pool{ New: func() any { return &Item{} }, }
ItemPool is a pool of Item values.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct { Key string // key of the item Value any // Value of the item Expiration time.Duration // Expiration duration of the item LastAccess time.Time // LastAccess time of the item AccessCount uint // AccessCount of times the item has been accessed }
Item is a struct that represents an item in the cache. It has a key, value, expiration duration, and a last access time field.
func (*Item) FieldByName ¶
FieldByName returns the value of the field of the Item struct with the given name. If the field does not exist, an empty reflect.Value is returned.
func (*Item) MarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (item *Item) UnmarshalBinary(data []byte) error { buf := bytes.NewBuffer(data) dec := gob.NewDecoder(buf) return dec.Decode(item) }
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*Item) Touch ¶
func (item *Item) Touch()
Touch updates the last access time of the item and increments the access count.
func (*Item) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
Click to show internal directories.
Click to hide internal directories.