public void put(final Object key, final Object value) throws CacheException { if (!isEnabled()) { return; } byte[] data; try { data = serializationStrategy.serialize(value); } catch (Exception e) { throw new CacheException(e); } String sKey = generateStringKeyFor(key); SerializedEntry entry = new SerializedEntry(value, data, store.getTimeSource()); store.putNoReturn(sKey, entry); // Now that the entry is shared we can drop the byte[] entry.nullByteArray(); }
public TimestampedValue createTimestampedValue(final Element element) { SerializationModeElementData value = new SerializationModeElementData(element); byte[] data; try { data = store.getSerializationStrategy().serialize(value); } catch (Exception e) { throw new CacheException(e); } TimestampedValue entry = new SerializedEntry<SerializationModeElementData>(value, data, element.getElementEvictionData().getCreationTime(), element.getElementEvictionData().getCreationTime()); return entry; }
public TimestampedValue createTimestampedValue(final Element element) { SerializationModeElementData value = new SerializationModeElementData(element); byte[] data; try { data = serializationStrategy.serialize(value); } catch (Exception e) { throw new CacheException(e); } // we can store null in the entry if we're doing copy on read value = copyOnRead ? null : value; if (element.usesCacheDefaultLifespan()) { return new SerializedEntry<SerializationModeElementData>(value, data, TimeUtil.toSecs(element.getElementEvictionData().getCreationTime()), TimeUtil.toSecs(element.getElementEvictionData().getCreationTime())); } else { int tti = element.getTimeToIdle(); int ttl = element.getTimeToLive(); return new CustomLifespanSerializedEntry<SerializationModeElementData>(value, data, tti, ttl, TimeUtil.toSecs(element.getElementEvictionData().getCreationTime()), TimeUtil.toSecs(element.getElementEvictionData().getCreationTime())); } }