1 Reply Latest reply on Mar 20, 2012 4:36 AM by Galder Zamarreño

    managing adding/removing entities to the cache

    Maxym Pendyshchuk Newbie

      Is here any way to control map operation in Infinispan? Something like triggers in Oracle Coherence? What I basically need is the following:


      1) before adding an entity to the cache map I would like to change the key under which this entry is going to be saved, or any property of the entity;

      2) before getting an entity from the cache I would like to modify key under which my application looks for entity in the cache (because it was modified before adding an entity, as written above);

      3) before returning an entity from the cache I would like to modify property of the entity;


      all above I need to know to use Infinispan as 2nd level hibernate cache and control some security issues. Sometimes I also need to reject getting an entity from the cache based on application security policies. Is it possible? Pure Listeners do not help me, they just can inform me about what is going on, but do not allow to influence anything. Am I wrong?

        • 1. Re: managing adding/removing entities to the cache
          Galder Zamarreño Master

          Re 1 and 2. When you implement a cache listener, you get callbacks for cache entry modified, you get the key, so in theory you could modify bits of the key, but when you implement a cache entry visited, any modifications to the key won't have effect on the key used for looking up. So, the answer is no.


          Re 3. You can do that wiht a cache listener, by modifying the value part when isPre=false.


          Btw, if you wanna do all this for 2LC, you need to get hold of the cache manager and get the caches for each entity/collection (normally we use the FQN of the cache, or region name configured)