node

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

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]) Cost

func (n *Node[K, V]) Cost() uint32

Cost returns the cost of the node.

func (*Node[K, V]) DecrementFrequency

func (n *Node[K, V]) DecrementFrequency()

DecrementFrequency decrements the frequency of the node.

func (*Node[K, V]) Expiration

func (n *Node[K, V]) Expiration() uint32

Expiration returns the expiration time.

func (*Node[K, V]) Frequency

func (n *Node[K, V]) Frequency() uint8

Frequency returns the frequency of the node.

func (*Node[K, V]) IncrementFrequency

func (n *Node[K, V]) IncrementFrequency()

IncrementFrequency increments the frequency of the node.

func (*Node[K, V]) IsExpired

func (n *Node[K, V]) IsExpired() bool

IsExpired returns true if node is expired.

func (*Node[K, V]) IsMain

func (n *Node[K, V]) IsMain() bool

IsMain returns true if node is in the main queue.

func (*Node[K, V]) IsSmall

func (n *Node[K, V]) IsSmall() bool

IsSmall returns true if node is in the small queue.

func (*Node[K, V]) Key

func (n *Node[K, V]) Key() K

Key returns the key.

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.

func (*Node[K, V]) Unmark

func (n *Node[K, V]) Unmark()

Unmark sets the status to unknown.

func (*Node[K, V]) Value

func (n *Node[K, V]) Value() V

Value returns the value.

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]

func (*Queue[K, V]) Clear

func (q *Queue[K, V]) Clear()

func (*Queue[K, V]) IsEmpty

func (q *Queue[K, V]) IsEmpty() bool

func (*Queue[K, V]) Len

func (q *Queue[K, V]) Len() int

func (*Queue[K, V]) Pop

func (q *Queue[K, V]) Pop() *Node[K, V]

func (*Queue[K, V]) Push

func (q *Queue[K, V]) Push(n *Node[K, V])

func (*Queue[K, V]) Remove

func (q *Queue[K, V]) Remove(n *Node[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.

func (*WriteTask[K, V]) IsAdd

func (t *WriteTask[K, V]) IsAdd() bool

IsAdd returns true if this is an add task.

func (*WriteTask[K, V]) IsClear

func (t *WriteTask[K, V]) IsClear() bool

IsClear returns true if this is a clear task.

func (*WriteTask[K, V]) IsClose

func (t *WriteTask[K, V]) IsClose() bool

IsClose returns true if this is a close task.

func (*WriteTask[K, V]) IsDelete

func (t *WriteTask[K, V]) IsDelete() bool

IsDelete returns true if this is a delete task.

func (*WriteTask[K, V]) IsUpdate

func (t *WriteTask[K, V]) IsUpdate() bool

IsUpdate returns true if this is an update task.

func (*WriteTask[K, V]) Node

func (t *WriteTask[K, V]) Node() *Node[K, V]

Node returns the node contained in the task. If node was not specified, it returns nil.

func (*WriteTask[K, V]) OldNode

func (t *WriteTask[K, V]) OldNode() *Node[K, V]

OldNode returns the old node contained in the task. If old node was not specified, it returns nil.

Jump to

Keyboard shortcuts

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