@Override public boolean insert(final Object key, final Object value, final Object currentVersion) { final Value newValue = new Value(currentVersion, nextTimestamp(), value); return cache.putIfAbsent(key, newValue) == null; }
@Override public int compareTo(final EvictionEntry o) { final long thisVal = this.value.getTimestamp(); final long anotherVal = o.value.getTimestamp(); return (thisVal < anotherVal ? -1 : (thisVal == anotherVal ? 0 : 1)); }
@Override public boolean insert(final Object key, final Object value, final Object currentVersion) { final Value newValue = new Value(currentVersion, nextTimestamp(), value); return cache.putIfAbsent(key, newValue) == null; }
@Override public int compareTo(final EvictionEntry o) { final long thisVal = this.value.getTimestamp(); final long anotherVal = o.value.getTimestamp(); return (thisVal < anotherVal ? -1 : (thisVal == anotherVal ? 0 : 1)); }
@Override public boolean insert(final Object key, final Object value, final Object currentVersion) { final Value newValue = new Value(currentVersion, nextTimestamp(), value); return cache.putIfAbsent(key, newValue) == null; }
@Override public int compareTo(final EvictionEntry o) { final long thisVal = this.value.getTimestamp(); final long anotherVal = o.value.getTimestamp(); return (thisVal < anotherVal ? -1 : (thisVal == anotherVal ? 0 : 1)); }
@Override public boolean insert(final Object key, final Object value, final Object currentVersion) { final Value newValue = new Value(currentVersion, nextTimestamp(), value); return cache.putIfAbsent(key, newValue) == null; }
public int compareTo(final EvictionEntry o) { final long thisVal = this.value.getTimestamp(); final long anotherVal = o.value.getTimestamp(); return (thisVal < anotherVal ? -1 : (thisVal == anotherVal ? 0 : 1)); }
@Override public boolean put(final Object key, final Object value, final long txTimestamp, final Object version) { while (true) { Expirable previous = cache.get(key); Value newValue = new Value(version, nextTimestamp(), value); if (previous == null) { if (cache.putIfAbsent(key, newValue) == null) { return true; } } else if (previous.isReplaceableBy(txTimestamp, version, versionComparator)) { if (cache.replace(key, previous, newValue)) { return true; } } else { return false; } } }
private List<EvictionEntry> searchEvictableEntries(final long timeToLive, final boolean limitSize) { List<EvictionEntry> entries = null; Iterator<Entry<Object, Expirable>> iter = cache.entrySet().iterator(); long now = nextTimestamp(); while (iter.hasNext()) { final Entry<Object, Expirable> e = iter.next(); final Object k = e.getKey(); final Expirable expirable = e.getValue(); if (expirable instanceof ExpiryMarker) { continue; } final Value v = (Value) expirable; if (timeToLive > 0 && v.getTimestamp() + timeToLive < now) { iter.remove(); } else if (limitSize) { if (entries == null) { // Use a List rather than a Set for correctness. Using a Set, especially a TreeSet // based on EvictionEntry.compareTo, causes evictions to be processed incorrectly // when two or more entries in the map have the same timestamp. In such a case, the // _first_ entry at a given timestamp is the only one that can be evicted because // TreeSet does not add "equivalent" entries. A second benefit of using a List is // that the cost of sorting the entries is not incurred if eviction isn't performed entries = new ArrayList<EvictionEntry>(cache.size()); } entries.add(new EvictionEntry(k, v)); } } return entries; }
public boolean put(final Object key, final Object value, final long txTimestamp, final Object version) { while (true) { Expirable previous = cache.get(key); Value newValue = new Value(version, nextTimestamp(), value); if (previous == null) { if (cache.putIfAbsent(key, newValue) == null) { return true; } } else if (previous.isReplaceableBy(txTimestamp, version, versionComparator)) { if (cache.replace(key, previous, newValue)) { return true; } } else { return false; } } }
private List<EvictionEntry> searchEvictableEntries(long timeToLive, boolean limitSize) { List<EvictionEntry> entries = null; Iterator<Entry<Object, Expirable>> iter = cache.entrySet().iterator(); long now = nextTimestamp(); while (iter.hasNext()) { final Entry<Object, Expirable> e = iter.next(); final Object k = e.getKey(); final Expirable expirable = e.getValue(); if (expirable instanceof ExpiryMarker) { continue; } final Value v = (Value) expirable; if (timeToLive > 0 && v.getTimestamp() + timeToLive < now) { iter.remove(); } else if (limitSize) { if (entries == null) { // Use a List rather than a Set for correctness. Using a Set, especially a TreeSet // based on EvictionEntry.compareTo, causes evictions to be processed incorrectly // when two or more entries in the map have the same timestamp. In such a case, the // _first_ entry at a given timestamp is the only one that can be evicted because // TreeSet does not add "equivalent" entries. A second benefit of using a List is // that the cost of sorting the entries is not incurred if eviction isn't performed entries = new ArrayList<EvictionEntry>(cache.size()); } entries.add(new EvictionEntry(k, v)); } } return entries; }
@Override public boolean put(final Object key, final Object value, final long txTimestamp, final Object version) { while (true) { Expirable previous = cache.get(key); Value newValue = new Value(version, nextTimestamp(), value); if (previous == null) { if (cache.putIfAbsent(key, newValue) == null) { return true; } } else if (previous.isReplaceableBy(txTimestamp, version, versionComparator)) { if (cache.replace(key, previous, newValue)) { return true; } } else { return false; } } }
private List<EvictionEntry> searchEvictableEntries(final long timeToLive, final boolean limitSize) { List<EvictionEntry> entries = null; Iterator<Entry<Object, Expirable>> iter = cache.entrySet().iterator(); long now = nextTimestamp(); while (iter.hasNext()) { final Entry<Object, Expirable> e = iter.next(); final Object k = e.getKey(); final Expirable expirable = e.getValue(); if (expirable instanceof ExpiryMarker) { continue; } final Value v = (Value) expirable; if (timeToLive > 0 && v.getTimestamp() + timeToLive < now) { iter.remove(); } else if (limitSize) { if (entries == null) { // Use a List rather than a Set for correctness. Using a Set, especially a TreeSet // based on EvictionEntry.compareTo, causes evictions to be processed incorrectly // when two or more entries in the map have the same timestamp. In such a case, the // _first_ entry at a given timestamp is the only one that can be evicted because // TreeSet does not add "equivalent" entries. A second benefit of using a List is // that the cost of sorting the entries is not incurred if eviction isn't performed entries = new ArrayList<EvictionEntry>(cache.size()); } entries.add(new EvictionEntry(k, v)); } } return entries; }
@Override public boolean put(final Object key, final Object value, final long txTimestamp, final Object version) { while (true) { Expirable previous = cache.get(key); Value newValue = new Value(version, nextTimestamp(), value); if (previous == null) { if (cache.putIfAbsent(key, newValue) == null) { return true; } } else if (previous.isReplaceableBy(txTimestamp, version, versionComparator)) { if (cache.replace(key, previous, newValue)) { return true; } } else { return false; } } }
private List<EvictionEntry> searchEvictableEntries(final long timeToLive, final boolean limitSize) { List<EvictionEntry> entries = null; Iterator<Entry<Object, Expirable>> iter = cache.entrySet().iterator(); long now = nextTimestamp(); while (iter.hasNext()) { final Entry<Object, Expirable> e = iter.next(); final Object k = e.getKey(); final Expirable expirable = e.getValue(); if (expirable instanceof ExpiryMarker) { continue; } final Value v = (Value) expirable; if (timeToLive > 0 && v.getTimestamp() + timeToLive < now) { iter.remove(); } else if (limitSize) { if (entries == null) { // Use a List rather than a Set for correctness. Using a Set, especially a TreeSet // based on EvictionEntry.compareTo, causes evictions to be processed incorrectly // when two or more entries in the map have the same timestamp. In such a case, the // _first_ entry at a given timestamp is the only one that can be evicted because // TreeSet does not add "equivalent" entries. A second benefit of using a List is // that the cost of sorting the entries is not incurred if eviction isn't performed entries = new ArrayList<EvictionEntry>(cache.size()); } entries.add(new EvictionEntry(k, v)); } } return entries; }
@Override public boolean insert(final Object key, final Object value, final Object currentVersion) { return map.putIfAbsent(key, new Value(currentVersion, nextTimestamp(hazelcastInstance), value)) == null; }
public boolean insert(final Object key, final Object value, final Object currentVersion) { return map.putIfAbsent(key, new Value(currentVersion, nextTimestamp(hazelcastInstance), value)) == null; }
@Override public boolean insert(final Object key, final Object value, final Object currentVersion) { return map.putIfAbsent(key, new Value(currentVersion, nextTimestamp(hazelcastInstance), value)) == null; }
@Override public boolean insert(final Object key, final Object value, final Object currentVersion) { return map.putIfAbsent(key, new Value(currentVersion, nextTimestamp(hazelcastInstance), value)) == null; }