springuser2014 / wro4j

Automatically exported from code.google.com/p/wro4j
0 stars 0 forks source link

Integrate LRU cache strategy #33

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Based on example from:
http://www.small-software.com/programming/java-mru-cache.html

Implement LRU cache strategy for caching wro resources.

Original issue reported on code.google.com by alex.obj...@gmail.com on 7 Jan 2010 at 8:18

GoogleCodeExporter commented 9 years ago
Also, investigate other implementation options.

Original comment by alex.obj...@gmail.com on 28 Jan 2010 at 12:58

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 11 Dec 2010 at 5:11

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 21 Mar 2011 at 7:19

GoogleCodeExporter commented 9 years ago
Alex, what's your idea about the caching strategy? What's the difference with 
issue #9?

Here's my opinion.

LRU is the default strategy in EhCache. Sadly LRU only is applied in 
MemoryStore eviction algorithms. Anyway I think that memory caching is not a 
good strategy for caching static resources. It's really hard to scale with this 
strategy since to estimate how many clients are hitting our webapp may be a 
titanic job (think about, for example, osgi-based applications).

Please, take a look at the following algorithm:
http://ehcache.org/documentation/cache_eviction_algorithms.html#Less_Frequently_
Used_LFU

When using DiskStore eviction algorithm that's the strategy. According to 
ehcache's documentation LFU can be better than LRU if cache elements follows 
the 80:20 rule (and that could be thinking in static resources). LFU relies on 
usage frequency determined by "hits" on elements. We can take advantage of disk 
caching creating a low-level cache based in some request-hashing stuff.

Hope I won't be too out of scope.

Original comment by lumen.ni...@gmail.com on 22 Mar 2011 at 3:41

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi Matias,

I think it is ok to have both LRU & LFU implementation and allow client to 
configure it with whatever suites better. 
Regarding the issue9 (ehcache integration) is that this issue doesn't require 
ehcache. 
I would like to keep any third party dependencies (like ehcache or spring) 
outside the wro4j-core module. This one should be as lightweight as possible. 
Any other features that depends on other frameworks should go to 
wro4j-extensions.

Thanks!

Original comment by alex.obj...@gmail.com on 22 Mar 2011 at 10:21

GoogleCodeExporter commented 9 years ago
Got it. Implementing LRU and LFU caches then.

Original comment by lumen.ni...@gmail.com on 23 Mar 2011 at 4:16

GoogleCodeExporter commented 9 years ago
Here's a patch for the LRU cache. Also attached some cosmetic changes to the 
main POM.

Original comment by lumen.ni...@gmail.com on 5 Apr 2011 at 1:35

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by lumen.ni...@gmail.com on 5 Apr 2011 at 1:42

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 5 Apr 2011 at 8:45