Skip to content

ayushman101/LRU_Cache_GO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LRU_CACHE

A key-value cache with the key and value can be any of the following types:

~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~int | ~int8 | ~int16 | ~int32 | ~int64 ~float32 | ~float64 | ~string

Use the main.go file and play with it to understand the cache package.

Creating a new LRU Cache

NewLRU:=cache.NewLRUCache[string,int](5)  

//where the key is of type string and value is of type int. 

NewLRUCache takes an int for initialising the cache by specifying its max capacity.

Put Function

NewLRU.Put("hello",20) NewLRU.Put("hey",30)

Get Function

val,err:=NewLRU.Get(key)

returns an error if there is no such key.

Display

NewLRU.Display()

Use the display function to view the entire LRU cache.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages