public TokyoTyrantTranscoder() { serializingTranscoder = new SerializingTranscoder(); serializingTranscoder.setPackZeros(false); }
public TokyoTyrantTranscoder(int maxSize) { serializingTranscoder = new SerializingTranscoder(maxSize); serializingTranscoder.setPackZeros(false); }
/** * XMemcached Constructor. * * @param inetSocketAddress * @param weight * @throws IOException */ public XMemcachedClient(final InetSocketAddress inetSocketAddress, int weight, CommandFactory cmdFactory) throws IOException { super(); if (inetSocketAddress == null) { throw new IllegalArgumentException("Null InetSocketAddress"); } if (cmdFactory == null) { throw new IllegalArgumentException("Null command factory."); } if (weight <= 0) { throw new IllegalArgumentException("weight<=0"); } this.buildConnector(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), cmdFactory, new SerializingTranscoder()); this.start0(); this.connect(new InetSocketAddressWrapper(inetSocketAddress, this.serverOrderCount.incrementAndGet(), weight, null)); }
/** * XMemcached Constructor.Every server's weight is one by default. * * @param cmdFactory command factory * @param addressList memcached server socket address list. * @throws IOException */ public XMemcachedClient(List<InetSocketAddress> addressList, CommandFactory cmdFactory) throws IOException { super(); if (cmdFactory == null) { throw new IllegalArgumentException("Null command factory."); } if (addressList == null || addressList.isEmpty()) { throw new IllegalArgumentException("Empty address list"); } BufferAllocator simpleBufferAllocator = new SimpleBufferAllocator(); this.buildConnector(new ArrayMemcachedSessionLocator(), simpleBufferAllocator, XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), cmdFactory, new SerializingTranscoder()); this.start0(); for (InetSocketAddress inetSocketAddress : addressList) { this.connect(new InetSocketAddressWrapper(inetSocketAddress, this.serverOrderCount.incrementAndGet(), 1, null)); } }
/** * Construct an AWSElasticCacheClient instance with config server addresses. * * @since 2.3.0 * @param addrs config server list. * @param pollConfigIntervalMills config poll interval in milliseconds. * @param commandFactory protocol command factory. * @throws IOException */ @SuppressWarnings("unchecked") public AWSElasticCacheClient(List<InetSocketAddress> addrs, long pollConfigIntervalMills, CommandFactory commandFactory) throws IOException { this(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), new TextCommandFactory(), new SerializingTranscoder(), (List<MemcachedClientStateListener>) Collections.EMPTY_LIST, (Map<InetSocketAddress, AuthInfo>) Collections.EMPTY_MAP, 1, XMemcachedClient.DEFAULT_CONNECT_TIMEOUT, null, true, addrs, pollConfigIntervalMills); }
public XMemcachedClient() throws IOException { super(); this.buildConnector(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), new TextCommandFactory(), new SerializingTranscoder()); this.start0(); }
/** * XMemcached constructor * * @param host server host * @param port server port * @param weight server weight * @throws IOException */ public XMemcachedClient(final String host, final int port, int weight) throws IOException { super(); if (weight <= 0) { throw new IllegalArgumentException("weight<=0"); } this.checkServerPort(host, port); this.buildConnector(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), new TextCommandFactory(), new SerializingTranscoder()); this.start0(); this.connect(new InetSocketAddressWrapper(this.newSocketAddress(host, port), this.serverOrderCount.incrementAndGet(), weight, null)); }
transcoder = new SerializingTranscoder();
public TokyoTyrantTranscoder(int maxSize) { serializingTranscoder = new SerializingTranscoder(maxSize); serializingTranscoder.setPackZeros(false); }
public TokyoTyrantTranscoder() { serializingTranscoder = new SerializingTranscoder(); serializingTranscoder.setPackZeros(false); }
@Bean public MemcachedClient memcachedClientForCluster() { List<InetSocketAddress> addressList = new ArrayList<InetSocketAddress>(); addressList.add(new InetSocketAddress("192.168.200.201", 11211)); addressList.add(new InetSocketAddress("192.168.200.201", 11212)); // 赋予权重 int[] weights = {1, 2}; XMemcachedClientBuilder builder = new XMemcachedClientBuilder(addressList, weights); // 设置连接池大小 builder.setConnectionPoolSize(10); // 协议工厂 builder.setCommandFactory(new TextCommandFactory()); // 分布策略,一致性哈希KetamaMemcachedSessionLocator或者ArraySessionLocator(默认) builder.setSessionLocator(new KetamaMemcachedSessionLocator()); // 设置序列化器 builder.setTranscoder(new SerializingTranscoder()); MemcachedClient memcachedClient = null; try { memcachedClient = builder.build(); } catch (IOException e) { e.printStackTrace(); } return memcachedClient; }
public MemcachedClient memcachedClientForCluster() { List<InetSocketAddress> addressList = new ArrayList<>(); addressList.add(new InetSocketAddress("192.168.0.108", 11211)); addressList.add(new InetSocketAddress("192.168.0.108", 11212)); // 赋予权重 int[] weights = {1, 2}; XMemcachedClientBuilder builder = new XMemcachedClientBuilder(addressList, weights); // 设置连接池大小 builder.setConnectionPoolSize(10); // 协议工厂 builder.setCommandFactory(new TextCommandFactory()); // 分布策略,一致性哈希KetamaMemcachedSessionLocator或者ArraySessionLocator(默认) builder.setSessionLocator(new KetamaMemcachedSessionLocator()); // 设置序列化器 builder.setTranscoder(new SerializingTranscoder()); MemcachedClient memcachedClient = null; try { memcachedClient = builder.build(); } catch (IOException e) { e.printStackTrace(); } return memcachedClient; }
/** * XMemcached Constructor.Every server's weight is one by default. * * @param cmdFactory command factory * @param addressList memcached server socket address list. * @throws IOException */ public XMemcachedClient(List<InetSocketAddress> addressList, CommandFactory cmdFactory) throws IOException { super(); if (cmdFactory == null) { throw new IllegalArgumentException("Null command factory."); } if (addressList == null || addressList.isEmpty()) { throw new IllegalArgumentException("Empty address list"); } BufferAllocator simpleBufferAllocator = new SimpleBufferAllocator(); this.buildConnector(new ArrayMemcachedSessionLocator(), simpleBufferAllocator, XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), cmdFactory, new SerializingTranscoder()); this.start0(); for (InetSocketAddress inetSocketAddress : addressList) { this.connect(new InetSocketAddressWrapper(inetSocketAddress, this.serverOrderCount.incrementAndGet(), 1, null)); } }
/** * XMemcached Constructor. * * @param inetSocketAddress * @param weight * @throws IOException */ public XMemcachedClient(final InetSocketAddress inetSocketAddress, int weight, CommandFactory cmdFactory) throws IOException { super(); if (inetSocketAddress == null) { throw new IllegalArgumentException("Null InetSocketAddress"); } if (cmdFactory == null) { throw new IllegalArgumentException("Null command factory."); } if (weight <= 0) { throw new IllegalArgumentException("weight<=0"); } this.buildConnector(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), cmdFactory, new SerializingTranscoder()); this.start0(); this.connect(new InetSocketAddressWrapper(inetSocketAddress, this.serverOrderCount.incrementAndGet(), weight, null)); }
/** * Construct an AWSElasticCacheClient instance with config server addresses. * * @since 2.3.0 * @param addrs config server list. * @param pollConfigIntervalMills config poll interval in milliseconds. * @param commandFactory protocol command factory. * @throws IOException */ @SuppressWarnings("unchecked") public AWSElasticCacheClient(List<InetSocketAddress> addrs, long pollConfigIntervalMills, CommandFactory commandFactory) throws IOException { this(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), new TextCommandFactory(), new SerializingTranscoder(), (List<MemcachedClientStateListener>) Collections.EMPTY_LIST, (Map<InetSocketAddress, AuthInfo>) Collections.EMPTY_MAP, 1, XMemcachedClient.DEFAULT_CONNECT_TIMEOUT, null, true, addrs, pollConfigIntervalMills); }
public XMemcachedClient() throws IOException { super(); this.buildConnector(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), new TextCommandFactory(), new SerializingTranscoder()); this.start0(); }
/** * XMemcached constructor * * @param host server host * @param port server port * @param weight server weight * @throws IOException */ public XMemcachedClient(final String host, final int port, int weight) throws IOException { super(); if (weight <= 0) { throw new IllegalArgumentException("weight<=0"); } this.checkServerPort(host, port); this.buildConnector(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), new TextCommandFactory(), new SerializingTranscoder()); this.start0(); this.connect(new InetSocketAddressWrapper(this.newSocketAddress(host, port), this.serverOrderCount.incrementAndGet(), weight, null)); }
transcoder = new SerializingTranscoder();
builder.setTranscoder(new SerializingTranscoder(CachedObject.MAX_SIZE));