glru

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: MIT Imports: 3 Imported by: 0

README

Glru

Go

A Simple Concurrent Safe LRU implementation in Golang.

Installation

go get github.com/ArunMurugan78/glru

Documentation

Overview

package glru encapsulates logic for the LRU cache.

Index

Constants

View Source
const DEFAULT_MAX_ITEMS = 10000

Variables

View Source
var ErrKeyNotFound = errors.New("key not found")

ErrKeyNotFound is returned by Get method when the key is not found.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxItems int // Defaults to DEFAULT_MAX_ITEMS
}

Config is passed to New().

type Glru

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

Glru is the main struct which implements the LRU cache.

func New

func New(config Config) *Glru

New returns a new initialized Glru instance.

func (*Glru) DeleteKey

func (cache *Glru) DeleteKey(key string)

func (*Glru) Get

func (cache *Glru) Get(key string) (interface{}, error)

Get returns the value association with the key. Returns ErrKeyNotFound if the key is not found in cache.

func (*Glru) Set

func (cache *Glru) Set(key string, value interface{})

Set adds the key-value pair to the cache.

Directories

Path Synopsis
package dll implements a Doubly linked List, with few needed methods.
package dll implements a Doubly linked List, with few needed methods.

Jump to

Keyboard shortcuts

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