Caching pattern: what you call (and how you change) OpenSymphony OsCache "group" paradigm

Caching issue for your guru caches.

Context

We have been using OpenSymphony OsCache for several years and will consider moving to a more efficient / stronger / faster / actively developed caching product.

Problem

We used the "group entry" OsCache function and did not find it elsewhere.

In short, OsCache allows you to specify one or more groups at the 'entry insert time. "Later you can cancel the" group of records "without knowing the keys for each record.

OsCache Example

Here is sample code using this mechanism:

Object[] groups = {"mammal", "Northern Hemisphere", "cloven-feet"}
myCache.put(myKey, myValue , groups );
// later you can flush all 'mammal' entries 
myCache.flushGroup("mammal")
// or flush all 'cloven-foot'
myCache.flushGroup("cloven-foot")

Alternative: Pairing Mechanism

, , "key matcher"

"" "" :

public class AnimalKey 
{
   String fRegion;
   String fPhylum;
   String fFootType;

   ..getters and setters go here

}

:

public class RegionMatcher implements ICacheKeyMatcher
{
   String fRegion;

   public RegionMatcher(String pRegion)
   {
    fRegion=pRegion;
   }

   public boolean isMatch(Obect pKey)
   {
      boolean bMatch=false;
      if (pKey instanceof AnimalKey)
      {
         AnimalKey key = (AninmalKey) pKey);
         bMatch=(fRegion.equals(key.getRegion());
      }
   }
}

:

myCache.put(new AnimalKey("North America","mammal", "chews-the-cud");
//remove all entries for 'north america'
IKeyMatcher myMatcher= new AnimalKeyMatcher("North America");
myCache.removeMatching(myMatcher);

, : , . ( , ).

  • (: ). ? OsCache "-". JbossCache, EhCache, , . Realm? ? ?
  • " /"?
  • (, ehcache, coherence, jbosscache).
  • jcache, ? (JSR-107)
  • " "? , . API, . (, -, , ).

+3
1

. O (n) , , , , , . , , , , . , .

, . , , , , . , , (, ). . IndexMap . , , .

http://code.google.com/p/concurrentlinkedhashmap/wiki/IndexableCache

+2
source

Source: https://habr.com/ru/post/1757045/


All Articles