O'Reilly logo

Instant Effective Caching with Ehcache by Daniel Wind

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The custom eviction algorithm (Advanced)

In this recipe, we will cover the following topics:

  • What an eviction algorithm is and how it works
  • Creating custom eviction algorithms using Ehcache

We will examine how to implement a custom eviction algorithm for our cached objects. We will re-use the Ehcache library classes as the basis for our own eviction algorithm.

Getting ready

Eviction algorithms are used to determine when to evict (or simply eject) an element from the cache layer when a certain condition has been met (for example, its life duration).

Ehcache also provides built-in eviction algorithms that you can use. However, there may be scenarios where you will want to control how to eject cached objects, and may want your code to react upon specific ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required