public SerializationKeySnapshot(SerializationStrategy strategy, Object key) throws IOException { this.keySerialized = strategy.serialize(key); }
private Object getElementDataForDMI(Element element) throws CacheException { AbstractElementData elementData; switch (valueMode) { case IDENTITY: return new IdentityModeElementData(element, Integer.MIN_VALUE); case SERIALIZATION: elementData = new SerializationModeElementData(element); try { return elementSerialization.serialize(elementData); } catch (IOException e) { throw new CacheException("Unexpected error while serializing the value " + element.getObjectValue(), e); } default: throw new UnsupportedOperationException("Value mode " + valueMode + " isn't supported"); } }
private Object getKeyForDMI(Element element) throws CacheException { switch (valueMode) { case IDENTITY: return element.getObjectKey(); case SERIALIZATION: try { return dsoSerialization.serialize(element.getObjectKey()); } catch (IOException e) { throw new CacheException("Unexpected error while serializing the key " + element.getObjectKey(), e); } default: throw new UnsupportedOperationException("Value mode " + valueMode + " isn't supported"); } }
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())); } }