Jodd cache collection

Jodd cache provides a set of cache implementations. Its hierarchy is as follows:

Among them,

Abstractcachemap is the default implementation of a cache map with timing and size. Its implementation class must:

Create a new cache map.

Implement your own prune policy.

Internally, reentranreadwritelock is used to synchronize. Because it is impossible to upgrade from a read lock to a write lock, pay attention to it in the get (object) method.

Fifocache: first in first out cache. The advantage is simple and efficient. The disadvantage is that it is not flexible and does not save commonly used cache objects in memory.

Lfucache: minimum number of accesses cache. The advantage is that the common cache is kept in memory, which will invalidate the scanning algorithm occasionally. The disadvantage is large acquisition consumption, that is, the algorithm can not quickly adapt to changing usage patterns, especially the temporary acquisition of clusters is invalid.

Lrucache: the cache has not been accessed recently. The consumption of cache objects is a constant. Simple and efficient, it is more suitable for a changing scene than FIFO. The disadvantage is that it may be occupied by the cache that will not be accessed again, especially when facing the acquisition type scan, it will not work at all. Then it is the most commonly used caching algorithm.

Timedcache does not limit the size and will be deleted only when the object expires. The standard chache method does not explicitly call prune, but performs scheduled deletion according to a defined delay.

Note that a filelfucache is also provided, which does not inherit abstractcachemap Using LFU to cache files into memory greatly speeds up the performance of accessing common files.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>