lru

How can I make my simple .NET LRU cache faster?

UPDATE: Hey guys thanks for the replies. Last night and tonight I tried a few different approaches and came up with one similar to the one laid out below by Jeff (I had even already done what he suggested in his update, and put together my own simple LL implementation for additional gains). Here is the code, at this point it doesn't lo...

LRU cache implementation in Javascript

Java has LinkedHashMap which gets you 99% there to an LRU cache. Is there a Javascript implementation of an LRU cache, preferably from a reputable source, that is: understandable efficient (amortized O(1) get/put/delete) ? I've been searching on the web but couldn't find one; I thought I found one on Ajax Design Patterns but it glos...

How can I delete LRU folders until 5GB free space is available

Given a folder \localhost\c$\work\ I'd like to run a powershell script every 15 minutes that ensures 5gb of free space is available. If < 5gb is available, remove the least recently used folder within work until >5gb is available. Gravy for nice output that can be redirected to a log file. Thoughts? ...

Question about LRU Cache implementation in Java

The standard example for implementing LRU Cache in Java points to the example depot url http://www.exampledepot.com/egs/java.util/coll_Cache.html How is removeEldestEntry called by default after just adding a new entry in the code snippet below? final int MAX_ENTRIES = 100; Map cache = new LinkedHashMap(MAX_ENTRIES+1, .75F, true) { ...

What type of java cache should be used in case data changes frequently?

I have a JSP which shows data by many aggregation types. E.g. By market, by category, by server type, etc.. What I have is the data by publisher and time. Publisher is the most granular level of data in my case. Now this data changes on every 1/2 an hour. The number of data per half an hour is almost 5K and anyone at a time looks data ...

LRU implementation in production code

Hi all, I have some C++ code where I need to implement cache replacement using LRU technique. So far I know two methods to implement LRU cache replacement: Using timeStamp for each time the cached data is accessed and finally comparing the timeStamps at time of replacement. Using a stack of cached items and moving them to the top if ...

Why is LRU better than FIFO?

Why is Least Recently Used better than FIFO in relation to page files? ...

Looking for a FIFO/LRU file storage system

I'm looking to implement a disk based caching system. The idea is to allocate a certain amount of disk space and save however much data fits in there, discarding of old files as I run out of space. LRU is my first choice of deletion strategy, but I'm willing to settle for FIFO. When googling for cache algorithms, the discussion seems to...

Limiting the size of a python dictionary

I'd like to work with a dict in python, but limit the number of key/value pairs to X. In other words, if the dict is currently storing X key/value pairs and I perform an insertion, I would like one of the existing pairs to be dropped. It would be nice if it was the least recently inserted/accesses key but that's not completely necessary....

What Does Memcached's LRU Actually Mean?

Memcached says it uses an LRU queue to do eviction (with a few rules based around slab sizes mixed in.) When they say least-recently-used, are they referring to least recently stored or least recently read? Their documentation seems ambiguous here. ...

LRU Cache design in C with of limited size

I'm now working on a software in mobile platform where memory is very small. In a I/O bottleneck function, I need read some bytes from a img file using seek operation(You can assume that seek is slower about 10 times than read directly from memmry). In my test, this function is called 7480325 times and read bytes from bytes_offset 6800 t...

Least Recently Used cache using C++

hi, I am trying to implement LRU Cache using C++ . I would like to know what is the best design for implementing them. I know LRU should provide find(), add an element and remove an element. The remove should remove the LRU element. what is the best ADTs to implement this For ex: If I use a map with element as value and time counter as ...