cache

package
v0.0.0-...-a4a72b7 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LFU

type LFU struct {
	// contains filtered or unexported fields
}

LFU the Least Frequently Used (LFU) page-replacement algorithm

func NewLFU

func NewLFU(capacity int) LFU

NewLFU init the LFU cache with capacity

func (*LFU) Get

func (c *LFU) Get(key string) any

Get the key in cache by LFU

func (*LFU) Put

func (c *LFU) Put(key string, value any)

Put the key in LFU cache

type LRU

type LRU struct {
	// contains filtered or unexported fields
}

func NewLRU

func NewLRU(capacity int) LRU

NewLRU represent initiate lru cache with capacity

func (*LRU) Get

func (c *LRU) Get(key string) any

Get value from lru if not found, return nil

func (*LRU) Put

func (c *LRU) Put(key string, value any)

Put cache with key and value to lru

Jump to

Keyboard shortcuts

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