@Override public void destroy() { super.destroy(); try { memcachedClient.shutdown(); } catch (Throwable e) { logger.warn(e.getMessage(), e); } } };
address += "," + backup; MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil.getAddresses(address)); final MemcachedClient memcachedClient = builder.build(); final int expiry = url.getParameter("expiry", 0); final String get = url.getParameter("get", "get");
throw new IllegalArgumentException("The memcached get method arguments mismatch, must only one arguments. interface: " + type.getName() + ", method: " + invocation.getMethodName() + ", url: " + url); return new RpcResult(memcachedClient.get(String.valueOf(invocation.getArguments()[0]))); } else if (set.equals(invocation.getMethodName())) { if (invocation.getArguments().length != 2) { throw new IllegalArgumentException("The memcached set method arguments mismatch, must be two arguments. interface: " + type.getName() + ", method: " + invocation.getMethodName() + ", url: " + url); memcachedClient.set(String.valueOf(invocation.getArguments()[0]), expiry, invocation.getArguments()[1]); return new RpcResult(); } else if (delete.equals(invocation.getMethodName())) { throw new IllegalArgumentException("The memcached delete method arguments mismatch, must only one arguments. interface: " + type.getName() + ", method: " + invocation.getMethodName() + ", url: " + url); memcachedClient.delete(String.valueOf(invocation.getArguments()[0])); return new RpcResult(); } else {
protected void configureClient(XMemcachedClient memcachedClient) { if (this.commandFactory.getProtocol() == Protocol.Kestrel) { memcachedClient.setOptimizeGet(false); } memcachedClient.setConnectTimeout(connectTimeout); memcachedClient.setSanitizeKeys(sanitizeKeys); memcachedClient.setKeyProvider(this.keyProvider); memcachedClient.setOpTimeout(this.opTimeout); memcachedClient.setHealSessionInterval(this.healSessionInterval); memcachedClient.setEnableHealSession(this.enableHealSession); memcachedClient.setMaxQueuedNoReplyOperations(this.maxQueuedNoReplyOperations); }
public final boolean prepend(String key, final Object value, final long timeout) throws TimeoutException, InterruptedException, MemcachedException { key = this.preProcessKey(key); byte[] keyBytes = this.checkStoreArguments(key, 0, value); return this.sendStoreCommand( this.commandFactory.createPrependCommand(key, keyBytes, value, false, this.transcoder), timeout); }
public final <T> boolean replace(String key, final int exp, final T value, final Transcoder<T> transcoder, final long timeout) throws TimeoutException, InterruptedException, MemcachedException { key = this.preProcessKey(key); byte[] keyBytes = this.checkStoreArguments(key, exp, value); return this.sendStoreCommand( this.commandFactory.createReplaceCommand(key, keyBytes, exp, value, false, transcoder), timeout); }
public final <T> boolean cas(String key, final int exp, final T value, final Transcoder<T> transcoder, final long timeout, final long cas) throws TimeoutException, InterruptedException, MemcachedException { key = this.preProcessKey(key); byte[] keyBytes = this.checkStoreArguments(key, 0, value); return this.sendStoreCommand( this.commandFactory.createCASCommand(key, keyBytes, exp, value, cas, false, transcoder), timeout); }
public final <T> boolean set(String key, final int exp, final T value, final Transcoder<T> transcoder, final long timeout) throws TimeoutException, InterruptedException, MemcachedException { key = this.preProcessKey(key); byte[] keyBytes = this.checkStoreArguments(key, exp, value); return this.sendStoreCommand( this.commandFactory.createSetCommand(key, keyBytes, exp, value, false, transcoder), timeout); }
public final boolean append(String key, final Object value, final long timeout) throws TimeoutException, InterruptedException, MemcachedException { key = this.preProcessKey(key); byte[] keyBytes = this.checkStoreArguments(key, 0, value); return this.sendStoreCommand( this.commandFactory.createAppendCommand(key, keyBytes, value, false, this.transcoder), timeout); }
private <T> boolean add0(String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws InterruptedException, TimeoutException, MemcachedException { byte[] keyBytes = this.checkStoreArguments(key, exp, value); return this.sendStoreCommand( this.commandFactory.createAddCommand(key, keyBytes, exp, value, false, transcoder), timeout); }
public <T> T withNamespace(String ns, MemcachedClientCallable<T> callable) throws MemcachedException, InterruptedException, TimeoutException { this.beginWithNamespace(ns); try { return callable.call(this); } finally { this.endWithNamespace(); } }
private final <T> Command sendGetMultiCommand(final Collection<String> keys, final CountDownLatch latch, final CommandType cmdType, final Transcoder<T> transcoder) throws InterruptedException, TimeoutException, MemcachedException { final Command command = this.commandFactory.createGetMultiCommand(keys, latch, cmdType, transcoder); this.sendCommand(command); return command; }
/** * Increase value by one * * @return * @throws MemcachedException * @throws InterruptedException * @throws TimeoutException */ public long incrementAndGet() throws MemcachedException, InterruptedException, TimeoutException { return this.memcachedClient.incr(this.key, 1, this.initialValue); }
public final <T> Map<String, T> get(final Collection<String> keyCollections, final long timeout, final Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException { return this.getMulti0(keyCollections, timeout, CommandType.GET_MANY, transcoder); }
public final <T> boolean set(final String key, final int exp, final T value, final Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException { return this.set(key, exp, value, transcoder, this.opTimeout); }
@SuppressWarnings("unchecked") public final boolean add(final String key, final int exp, final Object value, final long timeout) throws TimeoutException, InterruptedException, MemcachedException { return this.add(key, exp, value, this.transcoder, timeout); }
@SuppressWarnings("unchecked") public final boolean cas(final String key, final int exp, final Object value, final long timeout, final long cas) throws TimeoutException, InterruptedException, MemcachedException { return this.cas(key, exp, value, this.transcoder, timeout, cas); }
throw new IllegalArgumentException("The memcached get method arguments mismatch, must only one arguments. interface: " + type.getName() + ", method: " + invocation.getMethodName() + ", url: " + url); return new RpcResult(memcachedClient.get(String.valueOf(invocation.getArguments()[0]))); } else if (set.equals(invocation.getMethodName())) { if (invocation.getArguments().length != 2) { throw new IllegalArgumentException("The memcached set method arguments mismatch, must be two arguments. interface: " + type.getName() + ", method: " + invocation.getMethodName() + ", url: " + url); memcachedClient.set(String.valueOf(invocation.getArguments()[0]), expiry, invocation.getArguments()[1]); return new RpcResult(); } else if (delete.equals(invocation.getMethodName())) { throw new IllegalArgumentException("The memcached delete method arguments mismatch, must only one arguments. interface: " + type.getName() + ", method: " + invocation.getMethodName() + ", url: " + url); memcachedClient.delete(String.valueOf(invocation.getArguments()[0])); return new RpcResult(); } else {
address += "," + backup; MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil.getAddresses(address)); final MemcachedClient memcachedClient = builder.build(); final int expiry = url.getParameter("expiry", 0); final String get = url.getParameter("get", "get");
@Override public void destroy() { super.destroy(); try { memcachedClient.shutdown(); } catch (Throwable e) { logger.warn(e.getMessage(), e); } } };