Looking for a very simple Cache example

前端 未结 5 1960
没有蜡笔的小新
没有蜡笔的小新 2020-12-13 13:51

I\'m looking for a real simple example of how to add an object to cache, get it back out again, and remove it.

The second answer here is the kind of example I\'d lov

5条回答
  •  攒了一身酷
    2020-12-13 14:05

    Try this third party cache: CacheCrow, it is a simple LFU based cache.

    Install using powershell command in visual studio: Install-Package CacheCrow

    Code Snippet:

     // initialization of singleton class
        ICacheCrow cache = CacheCrow.Initialize(1000);
    
        // adding value to cache
        cache.Add("#12","Jack");
    
        // searching value in cache
        var flag = cache.LookUp("#12");
        if(flag)
        {
            Console.WriteLine("Found");
        }
    
        // removing value
        var value = cache.Remove("#12");
    

    For more information you can visit: https://github.com/RishabKumar/CacheCrow

提交回复
热议问题