Skip to content

apisani/LRUCache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Memory Cache

O(1) Get Value / O(1) Add Value / O(1) Update Value

Cache thread-safe implementation in C#, with eviction policy.

Documentation

XML documentation can be found in root:

cache_challenge\MemoryCache.xml

Unit Testing

Unit testing is available for that project using:

Code Coverage Percentage

80% - See below:

MemoryCache\Images\code_coverage_percentage.PNG

Implementation

Below is a short snippet for a simple usage case:

var cache = new Cache<int, string>(capacity: 100);
string valueInCache;

cache.AddOrUpdate(0, "Item 1");
cache.AddOrUpdate(1, "Item 2");
cache.AddOrUpdate(2, "Item 3");
cache.AddOrUpdate(3, "Item 4");
cache.AddOrUpdate(4, "Item 5");

cache.TryGetValue(0, out valueInCache)
console.writeLine(valueInCache);

cache.TryGetValue(3, out valueInCache)
console.writeLine(valueInCache);

Console.WriteLine(cache.Count);
Console.WriteLine(cache.IsFull);
Console.WriteLine(cache.Capacity);

About

Memory Cache code challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages