Package org.infinispan.container.entries

Examples of org.infinispan.container.entries.InternalCacheEntry.canExpire()


         private void fetchNext() {
            long currentTimeMillis = 0;
            while (it.hasNext()) {
               InternalCacheEntry e = it.next();
               final boolean canExpire = e.canExpire();
               if (canExpire && currentTimeMillis == 0) {
                  currentTimeMillis = timeService.wallClockTime();
               }
               if (!canExpire) {
                  next = e.getValue();
View Full Code Here


   @Test
   public void testDefaultExpiration() throws Exception {
      remoteCache.put("Key", "Value");
      InternalCacheEntry entry = getInternalCacheEntry(cache, "Key", "Value");
      assertTrue(entry.canExpire());
      assertEquals(3000, entry.getLifespan());
      assertEquals(2000, entry.getMaxIdle());
      Thread.sleep(5000);
      assertFalse(remoteCache.containsKey("Key"));
   }
View Full Code Here

   }

   @Override
   public InternalCacheEntry get(Object k) {
      InternalCacheEntry e = peek(k);
      if (e != null && e.canExpire()) {
         long currentTimeMillis = System.currentTimeMillis();
         if (e.isExpired(currentTimeMillis)) {
            entries.remove(k);
            e = null;
         } else {
View Full Code Here

   }

   @Override
   public boolean containsKey(Object k) {
      InternalCacheEntry ice = peek(k);
      if (ice != null && ice.canExpire() && ice.isExpired(System.currentTimeMillis())) {
         entries.remove(k);
         ice = null;
      }
      return ice != null;
   }
View Full Code Here

   }

   @Override
   public InternalCacheEntry remove(Object k) {
      InternalCacheEntry e = entries.remove(k);
      return e == null || (e.canExpire() && e.isExpired(System.currentTimeMillis())) ? null : e;
   }

   @Override
   public int size() {
      return entries.size();
View Full Code Here

      if (e != null) {
         e.setValue(v);
         if (lifespan > -1) e = e.setLifespan(lifespan);
         if (maxIdle > -1) e = e.setMaxIdle(maxIdle);

         if (e.canExpire()) {
            immortalEntries.remove(k);
            mortalEntries.put(k, e);
         }
      } else {
         e = mortalEntries.get(k);
View Full Code Here

         } else if (o instanceof InternalCacheEntry) {
            out.writeByte(MAGICNUMBER_INTERNAL_CACHED_ENTRY);
            InternalCacheEntry ice = (InternalCacheEntry) o;
            marshallObject(ice.getKey(), out, refMap);
            marshallObject(ice.getValue(), out, refMap);
            if (ice.canExpire()) {
               out.writeBoolean(true);
               writeUnsignedLong(out, ice.getCreated());
               out.writeLong(ice.getLifespan()); // could be negative so should not use unsigned longs
               writeUnsignedLong(out, ice.getLastUsed());
               out.writeLong(ice.getMaxIdle()); // could be negative so should not use unsigned longs
View Full Code Here

   public void writeExternal(Object subject, ObjectOutput output) throws IOException {
      InternalCacheEntry ice = (InternalCacheEntry) subject;
      output.writeObject(ice.getKey());
      output.writeObject(ice.getValue());
      if (ice.canExpire()) {
         output.writeBoolean(true);
         MarshallUtil.writeUnsignedLong(output, ice.getCreated());
         output.writeLong(ice.getLifespan()); // could be negative so should not use unsigned longs
         MarshallUtil.writeUnsignedLong(output, ice.getLastUsed());
         output.writeLong(ice.getMaxIdle()); // could be negative so should not use unsigned longs
View Full Code Here

      if (e != null) {
         e.setValue(v);
         if (lifespan > -1) e = e.setLifespan(lifespan);
         if (maxIdle > -1) e = e.setMaxIdle(maxIdle);

         if (e.canExpire()) {
            immortalEntries.remove(k);
            mortalEntries.put(k, e);
         }
      } else {
         e = mortalEntries.get(k);
View Full Code Here

   @Override
   public Object visitGetKeyValueCommand
         (InvocationContext ctx, GetKeyValueCommand command) throws Throwable {
      Object key = command.getKey();
      InternalCacheEntry entry = container.peek(key);
      if (entry != null && entry.canExpire() && entry.isExpired(timeService.wallClockTime()))
         notifier.notifyEntryExpired(cache, key, entry.getValue());

      return super.visitGetKeyValueCommand(ctx, command);
   }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.