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

Implementing LruCache with Objects

I am looking into implementing offline mode for android but to get there I need to implement a caching system. I read and people suggest LruCache and saw an example for images here LruCache Example. Now i am not caching images, I would like to cache…
jedgard
  • 868
  • 3
  • 23
  • 41
0
votes
1 answer

On Android, how many apps can be cached in memory at most?

When a user opens a different app, the previous app would be cached in the memory, except the user kills it explicitly, or the memory gets too low. As the user continues using different apps, more and more apps may be cached in the memory based on…
JackWM
  • 10,085
  • 22
  • 65
  • 92
0
votes
2 answers

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…
DKSRathore
  • 3,043
  • 6
  • 27
  • 36
0
votes
1 answer

Implement a LRU Cache in C++ - compilation error

I need to Implement a LRU Cache in C++. I have this code and i have problems while compiling: #include #include #include using namespace std; using namespace stdext; template struct LRUCacheEntry { …
user2456678
  • 33
  • 1
  • 5
0
votes
1 answer

LRU is used in file system cache?

I learned that due to computational overhead, true LRU is not implemented in virtual memory systems. So, why is the LRU algorithm feasible in a file cache? I think reason is may be the time field in an inode. Is that correct?
우지식
  • 21
  • 3
0
votes
1 answer

Ehcache and Apache JCS - how this work?

I need Lru cache to store several (~100) huge object (~10MB for example). I read about Ehcache and JSC and have one question. I have the case: I store 10 object in ehcache. Then i get one from them and assign to reference. Whether data in my…
user1711160
  • 169
  • 1
  • 10
0
votes
1 answer

Least Recently Used (LRU) paging algorithm always more efficient than FIFO?

I am doing a project simulating page replacement for my operating systems course. I have a simulator than runs all three algorithms on 1200 references. I am getting page fault rates, however, where the LRU algorithm is getting an equal to or lower…
Cory Gross
  • 36,833
  • 17
  • 68
  • 80
0
votes
1 answer

How can I improve my lru implementation

I've implemented LRU using hashtable+linked list. The hash table has chaining. The structure for code is as follows: struct Node{ int value; struct Node *next; struct Node* head; struct Node* tail; }; struct Node* lruhashtable[10]; struct Node*…
gizgok
  • 7,303
  • 21
  • 79
  • 124
0
votes
1 answer

C++ Index ordering issue with Boost MultiIndex as an LRU cache

I have the following LRU implementation made using Boost.MultiIndex bashed on this example. The problem is when I change the ordering of the index_by section (and update the enum index_idx accordingly) I get an error on the line that…
Soda Coader
  • 101
  • 12
0
votes
1 answer

How does Android system handle activities when it is stopped?

I am so curious about what will happen for the app's activities when the app is dismissed from the screen and the user switches to other apps. In the activity circle, the activity will reach onStop(), then how the system handle the activity before…
little-eyes
  • 945
  • 2
  • 9
  • 14
0
votes
3 answers

Page faults and LRU Algorithm

A main memory can retain up to 4 pages. Which page will be the first one to get a page fault if LRU algorithm is used on the following pages that is in order? 1,2,3,1,2,4,1,2,3 This is a test question which I thought there is no answer to. The main…
TtT23
  • 6,876
  • 34
  • 103
  • 174
0
votes
1 answer

boost multi index for a fixed sized multi-indexed polymorphic container

Still digging into C++/boost so any comments/feedback are welcome. I was playing with boost::unordered_maps and created a polymorphic example using shapes, about the time I had my head wrapped around that (mostly) I stumbled across the mru example…
user442585
  • 571
  • 1
  • 9
  • 17
0
votes
1 answer

how browsers clean the cache when the cache reach the limit?

I tried to look for this information on the net, but couldn't find good info about that. Do you know to describe how it works? 1. Is it some kind of LRU algorithm? 2. Does all the browsers share the same "cleaning algorithm? Thanks! Shay
Shay Tsadok
  • 913
  • 1
  • 7
  • 26
0
votes
1 answer

Virtual Memory, LRU, and Page Faults - Homework

I've been working on the following program and it feels like it's missing some information or a) and b) are a bit of a trick: The loop is executed as part of a program on a virtual memory system that employs 4KB pages. Assume that an LRU replacement…
-1
votes
1 answer

LRUCache using stack is not efficient enough

I am trying to solve the LeetCode problem 146. LRU Cache: Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the LRUCache class: LRUCache(int capacity) Initialize the LRU cache with positive size…
1 2 3
20
21