cache

package
v0.0.0-...-56f3d1a Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

README

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LRUCache

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

LRUCache cache struct

func NewLRUCache

func NewLRUCache(capacity int) *LRUCache

NewLRUCache New function

func (*LRUCache) Add

func (c *LRUCache) Add(key interface{}, value interface{}) bool

Add add a key-value pair to LRU cache Params:

  • key : cache key
  • value: cache value

Return:

  • evictOrNot: true if eviction occurs, false if not

func (*LRUCache) Del

func (c *LRUCache) Del(key interface{})

Del delete cached value from cache Params:

  • key: cache key

func (*LRUCache) EnlargeCapacity

func (c *LRUCache) EnlargeCapacity(newCapacity int) error

EnlargeCapacity enlarge the capacity of cache

func (*LRUCache) Get

func (c *LRUCache) Get(key interface{}) (interface{}, bool)

Get get cached value from LRU cache Params:

  • key: cache key

Return:

  • value: cache value
  • ok : true if found, false if not

func (*LRUCache) Keys

func (c *LRUCache) Keys() []interface{}

Keys get keys of items in cache

func (*LRUCache) Len

func (c *LRUCache) Len() int

Len get number of items in cache

type Pair

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

Pair <key, value>

Jump to

Keyboard shortcuts

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