use of net.spy.memcached.transcoders.SerializingTranscoder in project qi4j-sdk by Qi4j.
the class MemcacheImpl method get.
@Override
public T get(String key) {
Object value = client.get(prefix(key), new SerializingTranscoder());
client.touch(prefix(key), expiration);
if (value == null) {
return null;
}
return valueType.cast(value);
}
use of net.spy.memcached.transcoders.SerializingTranscoder in project druid by druid-io.
the class MemcachedCacheBenchmark method setUp.
@Override
protected void setUp() throws Exception {
SerializingTranscoder transcoder = new SerializingTranscoder(// 50 MB
50 * 1024 * 1024);
// disable compression
transcoder.setCompressionThreshold(Integer.MAX_VALUE);
client = new MemcachedClient(new ConnectionFactoryBuilder().setProtocol(ConnectionFactoryBuilder.Protocol.BINARY).setHashAlg(DefaultHashAlgorithm.FNV1A_64_HASH).setLocatorType(ConnectionFactoryBuilder.Locator.CONSISTENT).setDaemon(true).setFailureMode(FailureMode.Retry).setTranscoder(transcoder).setShouldOptimize(true).build(), AddrUtil.getAddresses(hosts));
cache = new MemcachedCache(Suppliers.<ResourceHolder<MemcachedClientIF>>ofInstance(StupidResourceHolder.create(client)), new MemcachedCacheConfig() {
@Override
public String getMemcachedPrefix() {
return "druid-memcached-benchmark";
}
@Override
public int getTimeout() {
return 30000;
}
@Override
public int getExpiration() {
return 3600;
}
}, MemcachedCacheTest.NOOP_MONITOR);
randBytes = new byte[objectSize * 1024];
new Random(0).nextBytes(randBytes);
}
use of net.spy.memcached.transcoders.SerializingTranscoder in project qi4j-sdk by Qi4j.
the class MemcacheImpl method remove.
@Override
public T remove(String key) {
String prefixedKey = prefix(key);
Object old = client.get(prefixedKey, new SerializingTranscoder());
if (old != null) {
client.delete(prefixedKey);
}
return valueType.cast(old);
}
Aggregations