@Override protected void setUp() throws Exception SerializingTranscoder transcoder = new SerializingTranscoder( 50 * 1024 * 1024 // 50 MB );
public static MemcachedCache create(final MemcachedCacheConfig config, String memcachedPrefix, int timeToLive) { try { SerializingTranscoder transcoder = new SerializingTranscoder(config.getMaxObjectSize()); // always no compression inside, we compress/decompress outside transcoder.setCompressionThreshold(Integer.MAX_VALUE); OperationQueueFactory opQueueFactory; int maxQueueSize = config.getMaxOperationQueueSize(); if (maxQueueSize > 0) { opQueueFactory = new ArrayOperationQueueFactory(maxQueueSize); } else { opQueueFactory = new LinkedOperationQueueFactory(); } String hostsStr = config.getHosts(); ConnectionFactory connectionFactory = new MemcachedConnectionFactoryBuilder() .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY) .setHashAlg(DefaultHashAlgorithm.FNV1A_64_HASH) .setLocatorType(ConnectionFactoryBuilder.Locator.CONSISTENT).setDaemon(true) .setFailureMode(FailureMode.Redistribute).setTranscoder(transcoder).setShouldOptimize(true) .setOpQueueMaxBlockTime(config.getTimeout()).setOpTimeout(config.getTimeout()) .setReadBufferSize(config.getReadBufferSize()).setOpQueueFactory(opQueueFactory).build(); return new MemcachedCache(new MemcachedClient(new MemcachedConnectionFactory(connectionFactory), AddrUtil.getAddresses(hostsStr)), config, memcachedPrefix, timeToLive); } catch (IOException e) { logger.error("Unable to create MemcachedCache instance.", e); throw Throwables.propagate(e); } }
/** * {@inheritDoc} */ @Override public Transcoder<Object> getDefaultTranscoder() { final SerializingTranscoder transcoder = new SerializingTranscoder(); transcoder.setCompressionThreshold( SerializingTranscoder.DEFAULT_COMPRESSION_THRESHOLD ); return new TranscoderWrapperStatisticsSupport( _statistics, transcoder ); }
/** * {@inheritDoc} */ @Override public Transcoder<Object> getDefaultTranscoder() { final SerializingTranscoder transcoder = new SerializingTranscoder(); transcoder.setCompressionThreshold( SerializingTranscoder.DEFAULT_COMPRESSION_THRESHOLD ); return new TranscoderWrapperStatisticsSupport( _statistics, transcoder ); }
this.tags = BasicTagList.of("ServerGroup", serverGroup.getName(), "APP", appName, "Id", String.valueOf(id)); this.decodingTranscoder = new SerializingTranscoder(Integer.MAX_VALUE); decodingTranscoder.setCompressionThreshold(Integer.MAX_VALUE);
public Transcoder<Object> getDefaultTranscoder() { return new SerializingTranscoder(); }
public Transcoder<Object> getDefaultTranscoder() { return new SerializingTranscoder(); }
public Transcoder<Object> getDefaultTranscoder() { return new SerializingTranscoder(); }
public Transcoder<Object> getDefaultTranscoder() { return new SerializingTranscoder(); }
public Transcoder<Object> getDefaultTranscoder() { return new SerializingTranscoder(); }
public Transcoder<Object> getDefaultTranscoder() { return new SerializingTranscoder(); }
@Override public void put( String key, T value ) { client.set( prefix( key ), expiration, value, new SerializingTranscoder() ); }
/** * {@inheritDoc} */ @Override public Transcoder<Object> getDefaultTranscoder() { final SerializingTranscoder transcoder = new SerializingTranscoder(); transcoder.setCompressionThreshold( SerializingTranscoder.DEFAULT_COMPRESSION_THRESHOLD ); return new TranscoderWrapperStatisticsSupport( _statistics, transcoder ); }
/** * {@inheritDoc} */ @Override public Transcoder<Object> getDefaultTranscoder() { final SerializingTranscoder transcoder = new SerializingTranscoder(); transcoder.setCompressionThreshold( SerializingTranscoder.DEFAULT_COMPRESSION_THRESHOLD ); return new TranscoderWrapperStatisticsSupport( _statistics, transcoder ); }
@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 ); }
@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 ); }
/** * Attempt to get the object represented by the given serialized bytes. */ private Object deserialize() { SerializingTranscoder tc = new SerializingTranscoder(); CachedData d = new CachedData(this.getItemFlags(), this.getValue(), CachedData.MAX_SIZE); Object rv = null; rv = tc.decode(d); return rv; }
/** * Attempt to get the object represented by the given serialized bytes. */ private Object deserialize() { SerializingTranscoder tc = new SerializingTranscoder(); CachedData d = new CachedData(this.getItemFlags(), this.getValue(), CachedData.MAX_SIZE); Object rv = null; rv = tc.decode(d); return rv; }
/** * Attempt to get the object represented by the given serialized bytes. */ private Object deserialize() { SerializingTranscoder tc = new SerializingTranscoder(); CachedData d = new CachedData(this.getItemFlags(), this.getValue(), CachedData.MAX_SIZE); Object rv = null; rv = tc.decode(d); return rv; }
public static MemcachedCache create(final MemcachedCacheConfig config, String memcachedPrefix, int timeToLive) { try { SerializingTranscoder transcoder = new SerializingTranscoder(config.getMaxObjectSize()); // always no compression inside, we compress/decompress outside transcoder.setCompressionThreshold(Integer.MAX_VALUE); OperationQueueFactory opQueueFactory; int maxQueueSize = config.getMaxOperationQueueSize(); if (maxQueueSize > 0) { opQueueFactory = new ArrayOperationQueueFactory(maxQueueSize); } else { opQueueFactory = new LinkedOperationQueueFactory(); } String hostsStr = config.getHosts(); ConnectionFactory connectionFactory = new MemcachedConnectionFactoryBuilder() .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY) .setHashAlg(DefaultHashAlgorithm.FNV1A_64_HASH) .setLocatorType(ConnectionFactoryBuilder.Locator.CONSISTENT).setDaemon(true) .setFailureMode(FailureMode.Redistribute).setTranscoder(transcoder).setShouldOptimize(true) .setOpQueueMaxBlockTime(config.getTimeout()).setOpTimeout(config.getTimeout()) .setReadBufferSize(config.getReadBufferSize()).setOpQueueFactory(opQueueFactory).build(); return new MemcachedCache(new MemcachedClient(new MemcachedConnectionFactory(connectionFactory), AddrUtil.getAddresses(hostsStr)), config, memcachedPrefix, timeToLive); } catch (IOException e) { logger.error("Unable to create MemcachedCache instance.", e); throw Throwables.propagate(e); } }