Documentation
¶
Index ¶
- type Node
- func (n *Node[K, V]) Cost() uint32
- func (n *Node[K, V]) DecrementFrequency()
- func (n *Node[K, V]) Expiration() uint32
- func (n *Node[K, V]) Frequency() uint8
- func (n *Node[K, V]) IncrementFrequency()
- func (n *Node[K, V]) IsExpired() bool
- func (n *Node[K, V]) IsMain() bool
- func (n *Node[K, V]) IsSmall() bool
- func (n *Node[K, V]) Key() K
- func (n *Node[K, V]) MarkMain()
- func (n *Node[K, V]) MarkSmall()
- func (n *Node[K, V]) ResetFrequency()
- func (n *Node[K, V]) Unmark()
- func (n *Node[K, V]) Value() V
- type Queue
- type WriteTask
- func NewAddTask[K comparable, V any](n *Node[K, V]) WriteTask[K, V]
- func NewClearTask[K comparable, V any]() WriteTask[K, V]
- func NewCloseTask[K comparable, V any]() WriteTask[K, V]
- func NewDeleteTask[K comparable, V any](n *Node[K, V]) WriteTask[K, V]
- func NewUpdateTask[K comparable, V any](n, oldNode *Node[K, V]) WriteTask[K, V]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node[K comparable, V any] struct { // contains filtered or unexported fields }
Node is an entry in the cache containing the key, value, cost, access and write metadata.
func New ¶
func New[K comparable, V any](key K, value V, expiration, cost uint32) *Node[K, V]
New creates a new Node.
func (*Node[K, V]) DecrementFrequency ¶
func (n *Node[K, V]) DecrementFrequency()
DecrementFrequency decrements the frequency of the node.
func (*Node[K, V]) Expiration ¶
Expiration returns the expiration time.
func (*Node[K, V]) IncrementFrequency ¶
func (n *Node[K, V]) IncrementFrequency()
IncrementFrequency increments the frequency of the node.
func (*Node[K, V]) MarkMain ¶
func (n *Node[K, V]) MarkMain()
MarkMain sets the status to the main queue.
func (*Node[K, V]) MarkSmall ¶
func (n *Node[K, V]) MarkSmall()
MarkSmall sets the status to the small queue.
func (*Node[K, V]) ResetFrequency ¶
func (n *Node[K, V]) ResetFrequency()
ResetFrequency resets the frequency.
type Queue ¶
type Queue[K comparable, V any] struct { // contains filtered or unexported fields }
func NewQueue ¶
func NewQueue[K comparable, V any]() *Queue[K, V]
type WriteTask ¶
type WriteTask[K comparable, V any] struct { // contains filtered or unexported fields }
WriteTask is a set of information to update the cache: node, reason for write, difference after node cost change, etc.
func NewAddTask ¶
func NewAddTask[K comparable, V any](n *Node[K, V]) WriteTask[K, V]
NewAddTask creates a task to add a node to policies.
func NewClearTask ¶
func NewClearTask[K comparable, V any]() WriteTask[K, V]
NewClearTask creates a task to clear policies.
func NewCloseTask ¶
func NewCloseTask[K comparable, V any]() WriteTask[K, V]
NewCloseTask creates a task to clear policies and stop all goroutines.
func NewDeleteTask ¶
func NewDeleteTask[K comparable, V any](n *Node[K, V]) WriteTask[K, V]
NewDeleteTask creates a task to delete a node from policies.
func NewUpdateTask ¶
func NewUpdateTask[K comparable, V any](n, oldNode *Node[K, V]) WriteTask[K, V]
NewUpdateTask creates a task to update the node in the policies.