public void gotData(String k, int flags, long cas, byte[] data) { if (!key.equals(k)) log.warn("Wrong key returned. Key - {}; Returned Key {}", key, k); if (data != null) { if(getAndTouchDataSize == null) getAndTouchDataSize = EVCacheMetricsFactory.getDistributionSummary(appName + "-GATOperation-DataSize", appName, serverGroup.getName()); if (getAndTouchDataSize != null) getAndTouchDataSize.record(data.length); } val = new CASValue<T>(cas, tc.decode(new CachedData(flags, data, tc.getMaxSize()))); } });
@Deprecated public <T> Future<Boolean> add(String key, int exp, T value, final Transcoder<T> tc, EVCacheLatch latch) throws Exception { final CachedData cd; if (value instanceof CachedData) { cd = (CachedData) value; } else { if(tc == null) { cd = getTranscoder().encode(value); } else { cd = tc.encode(value); } } return _add(key, exp, cd, latch); }
/** * {@inheritDoc} */ public boolean asyncDecode( final CachedData cachedData ) { return _delegate.asyncDecode( cachedData ); }
@Override public <T> T get(String key, Transcoder<T> tc) { CachedData data = theMap.get(key); return data != null ? tc.decode(data) : null; }
@SuppressWarnings("unchecked") public void gotData(String k, int flags, byte[] data) { if (data != null) { if(getDataSize == null) getDataSize = EVCacheMetricsFactory.getDistributionSummary(appName + "-GetOperation-DataSize", appName, serverGroup.getName()); if (getDataSize != null) getDataSize.record(data.length); } if (!key.equals(k)) log.warn("Wrong key returned. Key - {}; Returned Key {}", key, k); if (tc == null) { if (tcService == null) { log.error("tcService is null, will not be able to decode"); throw new RuntimeException("TranscoderSevice is null. Not able to decode"); } else { final Transcoder<T> t = (Transcoder<T>) getTranscoder(); val = tcService.decode(t, new CachedData(flags, data, t.getMaxSize())); } } else { if (tcService == null) { log.error("tcService is null, will not be able to decode"); throw new RuntimeException("TranscoderSevice is null. Not able to decode"); } else { val = tcService.decode(tc, new CachedData(flags, data, tc.getMaxSize())); } } }
@Override public Map<String, T> get() { Map<String, T> retVal = new HashMap<>(); while (keys.hasNext()) { String key = keys.next(); CachedData data = theMap.get(key); retVal.put(key, data != null ? tc.decode(data) : null); } return retVal; }
@Override public void gotData(String k, int flags, byte[] data) { if (data != null) { if(bulkDataSize == null) bulkDataSize = EVCacheMetricsFactory.getDistributionSummary(appName + "-BulkOperation-DataSize", appName, serverGroup.getName()); if (bulkDataSize != null) bulkDataSize.record(data.length); } m.put(k, tcService.decode(tc, new CachedData(flags, data, tc.getMaxSize()))); }
public void gotData(String key, String subkey, int flags, byte[] data) { assert key.equals(k) : "Wrong key returned"; list.add(tc.decode(new CachedData(flags, data, tc .getMaxSize()))); } });
@Deprecated public <T> Future<Boolean> add(String key, int exp, T value, Transcoder<T> tc) throws Exception { final CachedData cd; if (value instanceof CachedData) { cd = (CachedData) value; } else { if(tc == null) { cd = getTranscoder().encode(value); } else { cd = tc.encode(value); } } return _add(key, exp, cd, null); }
private T getFromObj(Object obj) { if(obj != null && obj instanceof EVCacheValue) { final EVCacheValue val = (EVCacheValue)obj; final CachedData cd = new CachedData(val.getFlags(), val.getValue(), CachedData.MAX_SIZE); if(tc == null) { if(_transcoder == null) { return (T)client.getTranscoder().decode(cd); } else { return (T)_transcoder.decode(cd); } } else { return tc.decode(cd); } } else { return null; } }
/** * {@inheritDoc} */ public int getMaxSize() { return _delegate.getMaxSize(); }
/** * {@inheritDoc} */ public boolean asyncDecode( final CachedData cachedData ) { return _delegate.asyncDecode( cachedData ); }
public void gotData(String key, String subkey, int flags, byte[] data) { assert key.equals(k) : "Wrong key returned"; set.add(tc.decode(new CachedData(flags, data, tc .getMaxSize()))); } });
@Deprecated public <T> Future<Boolean> add(String key, int exp, T value) throws Exception { final CachedData cd; if (value instanceof CachedData) { cd = (CachedData) value; } else { cd = getTranscoder().encode(value); } return _add(key, exp, cd, null); }
final T theValue = data != null ? tc.decode(data) : null;
/** * {@inheritDoc} */ public int getMaxSize() { return _delegate.getMaxSize(); }
/** * Perform a decode. */ public <T> Future<T> decode(final Transcoder<T> tc, final CachedData cachedData) { assert !pool.isShutdown() : "Pool has already shut down."; TranscodeService.Task<T> task = new TranscodeService.Task<T>(new Callable<T>() { public T call() { return tc.decode(cachedData); } }); if (tc.asyncDecode(cachedData)) { this.pool.execute(task); } return task; }
public void gotData(String key, String subkey, int flags, byte[] data) { assert key.equals(k) : "Wrong key returned"; map.put(subkey, tc.decode(new CachedData(flags, data, tc .getMaxSize()))); } });
@Deprecated public <T> Future<Boolean> set(String key, T value, int timeToLive, EVCacheLatch evcacheLatch) throws Exception { final CachedData cd; if (value instanceof CachedData) { cd = (CachedData) value; } else { cd = getTranscoder().encode(value); } return _set(key, cd, timeToLive, evcacheLatch); }