Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-5482

JSR-107 - Provide mechanism to handle expiration events

    XMLWordPrintable

Details

    • Feature Request
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Done
    • None
    • 8.1.0.Final
    • JCache
    • None

    Description

      Currently, expiration events are supported only by embedded mode & additionally require entry to be accessed in order to be created. This can lead to CacheEntryExpiredListener not being notified when an entry expires.

      Note: Not covered by TCK tests.

      Example:

         @Test
         public void testExpiration(Method m) {
            Cache<String, String> cache1 = getCache1(m);
            Cache<String, String> cache2 = getCache2(m);
      
            TestExpiredListener listener = new TestExpiredListener();
            MutableCacheEntryListenerConfiguration conf1 = new MutableCacheEntryListenerConfiguration(FactoryBuilder.factoryOf(listener), null, false, false);
            cache1.registerCacheEntryListener(conf1);
            cache2.put("key1", "val1");
            sleep(5000);
            // Required by embedded JCache implementation to work 
            assert cache1.get("key1") == null;
            // Failing for remote JCache implementation
            assertEquals(1, listener.invocationCount);
         }
      
         private static class TestExpiredListener implements CacheEntryExpiredListener, Serializable {
      
            private int invocationCount;
      
            @Override
            public void onExpired(Iterable iterable) throws CacheEntryListenerException {
               Iterator iterator = iterable.iterator();
               while (iterator.hasNext()) {
                  iterator.next();
                  invocationCount++;
               }
            }
         }
      

      Attachments

        Activity

          People

            gfernand@redhat.com Gustavo Fernandes (Inactive)
            mcimbora_jira Matej ─îimbora (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: