Questions tagged [lru]

LRU is a family of caching algorithms, where LRU stands for least recently used.

LRU is a family of caching algorithms, where LRU stands for least recently used. As the name implies, a cache discards the least recently used items from the cache, when the contents exceed a certain threshold. In this algorithm, writes are quite expensive, as you always need to write the change the usage information when you use an item.

More information at Wikipedia.

304 questions
0
votes
1 answer

How to use RoboSpice cache types

Note: this is general question of person new to caching mechanisms on Android. Why RS uses LRU caching in FlickrSpiceService sample? There is LruCacheBitmapObjectPersister: @Override public CacheManager createCacheManager(Application application)…
Marian Paździoch
  • 8,813
  • 10
  • 58
  • 103
0
votes
1 answer

LRU sorted by score in C++, is there such container?

I need to implement a very efficient cache LRU with the following properties: entries are indices in a vector of cache entries, each cache hit updates an empirical score, computed from some values that can be kept in the container value, like number…
0
votes
1 answer

How to simulate a heavy used memory

I need to perform an experiment to demonstrate the LRU (least recent used) eviction behavior of Linux virtual memory management. In order to do so, I wrote the following code to count pages faults (using /usr/bin/time -v). It first allocates a…
qweruiop
  • 3,156
  • 6
  • 31
  • 55
0
votes
1 answer

ExpiringMap or TTL based Cache

http://www.java2s.com/Code/Java/Collections-Data-Structure/ExpiringMap.htm Q1) I was looking at the above Caching code. I am confused why we need a lock when getLastAccessTime is called. That method is only being called by the Expirer thread. Q2)…
Paul
  • 187
  • 1
  • 2
  • 12
0
votes
1 answer

Which part of the Linux kernel code is responsible for implementing LRU?

I've been reading the documentation and the comments in the source code files but cannot figure out the exact function/code which is responsible for implementing the LRU in the latest release of the kernel. I want to make slight modifications to it,…
user1836386
  • 57
  • 1
  • 8
0
votes
1 answer

Redis Vs. Memcached

I am using memcached right now as a LRU cache to cache big data. I've set the max object size to 128 MB (I know this is inefficient and not recommended) and total memcached to 1 GB. But 128 MB is not enough for my purposes so I am planning to move…
yogk
  • 271
  • 5
  • 15
0
votes
1 answer

Resizing LRU-cache

I am using LRU-caching package for caching string data. Based on current heap size of V8, I need to change the size of the cache, but this package doesn't provide such kind of interface. I need to achieve this in optimal way(not copying the whole…
someUser
  • 965
  • 12
  • 24
0
votes
1 answer

how to determine a page(or file) is least used.how to determine calculate method,which is about Least Recently Used

i know about LRU algorithm,but how to determine the calculation is key point.if the space is not enough,i want to find some files's weight which are below,then delete them and put in some files's weight which are high weight.some one ever did this?
0
votes
1 answer

How to display image in a listview with lrucache?

I'm a beginner at Android development. I want to display the images in small size from sd card. Because of large image that is to slow, so I need to use a LruCache, but it doesn't work. I'm also using SwipeView. Here is a FileExplorer example. This…
0
votes
1 answer

the sequence of insert and erase using stl::list

When I am doing practice on leetcode, I met a problem like this: I used a stl::list container as cache for LRU algorithm. But the sequence of erasing an item and inserting an item made the result different. I know that it is actually a double list…
maoyang
  • 1,067
  • 1
  • 11
  • 11
0
votes
1 answer

LRU cache with Doubly Linked List from scratch - moveToHead (Java)

I have implemented a simple LRU cache as a doubly linked list written manually from scratch. The cache is filled with objects Request distinguished by their numeric (integer) ID. These Request objects are generated as a stream of L random…
Kotsos
  • 229
  • 4
  • 15
0
votes
0 answers

How to size LRU cache for custom data type

When using LRU for bitmap the number 1024 is used in the calculation for the number of items to cache. I want to cache a custom datatype. Say MyDog. How do I size the cache? Also, does anyone have a simple example? I have the google example for…
user3093402
  • 1,419
  • 4
  • 20
  • 28
0
votes
1 answer

behaviour of unordered_map reserve

The maximum size of my collection (an unordered_map) is known beforehand, so I want to reserve memory at start up for optimization. Does the member function reserve() achieve that purpose? The documentation says it will reserve the right number of…
danny
  • 1,101
  • 1
  • 12
  • 34
0
votes
1 answer

Best way to cache contacts photo

I'm trying to display all contact list in my activity, what is the best way for showing/caching the contact photos? assuming I have 1000+ contacts and all of them have profile photo. I already read about Google volley library but it's for loading…
Udi Oshi
  • 6,787
  • 7
  • 47
  • 65
0
votes
1 answer

Maxmemory Samples in Redis

I am using "maxmemory-policy allkeys-lru"for key eviction in REDIS. REDIS picks the keys randomly for eviction.Is there a way to see the random sample picked by the REDIS for eviction of key.
Vivek
  • 152
  • 1
  • 4
  • 10