public boolean set(String key, byte[] raw, int exp) throws KeyValueStoreClientException { if (!isAlive()) { throw(new KeyValueStoreClientException(new IllegalStateException("client not established"))); } boolean result = false; try { result = _client.set(key, exp, raw); } catch (Exception error) { throw(new KeyValueStoreClientException(error)); } return result; }
public boolean shutdown() throws KeyValueStoreClientException { if (_client != null) { try { _client.shutdown(); } catch (IOException error) { throw(new KeyValueStoreClientException(error)); } finally { _client = null; } } return true; }
public boolean add(String key, byte[] raw, int exp) throws KeyValueStoreClientException { if (!isAlive()) { throw(new KeyValueStoreClientException(new IllegalStateException("client not established"))); } boolean result = false; try { result = _client.add(key, exp, raw); } catch (Exception error) { throw(new KeyValueStoreClientException(error)); } return result; }
public boolean delete(String key) throws KeyValueStoreClientException { if (!isAlive()) { throw(new KeyValueStoreClientException(new IllegalStateException("client not established"))); } data.remove(key); return true; }
public boolean delete(String key) throws KeyValueStoreClientException { if (!isAlive()) { throw(new KeyValueStoreClientException(new IllegalStateException("client not established"))); } boolean result; try { Future<Boolean> f = _client.delete(key); result = f.get(_timeoutInMs, TimeUnit.MILLISECONDS); } catch (Exception error) { throw(new KeyValueStoreClientException(error)); } return result; } }
public byte[] get(String key) throws KeyValueStoreClientException { if (!isAlive()) { throw(new KeyValueStoreClientException(new IllegalStateException("client not established"))); } byte[] raw = null; try { raw = _client.get(key); } catch (Exception error) { throw(new KeyValueStoreClientException(error)); } return raw; }
public byte[] get(String key) throws KeyValueStoreClientException { if (!isAlive()) { throw(new KeyValueStoreClientException(new IllegalStateException("client not established"))); } byte[] raw = null; try { Future<byte[]> f = _client.asyncGet(key, _transcoder); raw = f.get(_timeoutInMs, TimeUnit.MILLISECONDS); } catch (Exception error) { throw(new KeyValueStoreClientException(error)); } return raw; }
public boolean delete(String key) throws KeyValueStoreClientException { if (!isAlive()) { throw(new KeyValueStoreClientException(new IllegalStateException("client not established"))); } boolean result = false; try { result = _client.delete(key); } catch (Exception error) { throw(new KeyValueStoreClientException(error)); } return result; } }
public boolean set(String key, byte[] raw, int exp) throws KeyValueStoreClientException { if (!isAlive()) { throw(new KeyValueStoreClientException(new IllegalStateException("client not established"))); } boolean result; try { Future<Boolean> f = _client.set(key, exp, raw, _transcoder); result = f.get(_timeoutInMs, TimeUnit.MILLISECONDS); } catch (Exception error) { throw(new KeyValueStoreClientException(error)); } return result; }
public boolean add(String key, byte[] raw, int exp) throws KeyValueStoreClientException { if (!isAlive()) { throw(new KeyValueStoreClientException(new IllegalStateException("client not established"))); } boolean result; try { Future<Boolean> f = _client.add(key, exp, raw, _transcoder); result = f.get(_timeoutInMs, TimeUnit.MILLISECONDS); } catch (Exception error) { throw(new KeyValueStoreClientException(error)); } return result; }
public boolean add(String key, byte[] raw, int exp) throws KeyValueStoreClientException { if (!isAlive()) { throw(new KeyValueStoreClientException(new IllegalStateException("client not established"))); } boolean notExists = false; synchronized(data) { notExists = !data.containsKey(key); if (notExists) { data.put(key, new Entry(raw, expiryTimeMillis(exp))); } } return notExists; }
public boolean set(String key, byte[] raw, int exp) throws KeyValueStoreClientException { if (!isAlive()) { throw(new KeyValueStoreClientException(new IllegalStateException("client not established"))); } data.put(key, new Entry(raw, expiryTimeMillis(exp))); return true; }
public byte[] get(String key) throws KeyValueStoreClientException { if (!isAlive()) { throw(new KeyValueStoreClientException(new IllegalStateException("client not established"))); } byte[] raw = null; synchronized(data) { Entry entry = data.get(key); if ( entry != null) { long exp = entry.getExpiry(); if (System.currentTimeMillis() < exp || exp == FOREVER) { raw = entry.getData(); } else { data.remove(key); } } } return raw; }
public boolean establish() throws KeyValueStoreClientException { if (_client != null) { if (!_client.isShutdown()) { return true; } else { shutdown(); } } this._builder = getClientBuilder(_serverString); try { this._client = _builder.build(); } catch (IOException error) { throw(new KeyValueStoreClientException(error)); } return true; }
public boolean establish() throws KeyValueStoreClientException { if (_client != null) { shutdown(); } try { ConnectionFactory cf = getConnectionFactory(); if (cf == null) { this._client = new MemcachedClient(AddrUtil.getAddresses(_serverString)); } else { this._client = new MemcachedClient(cf, AddrUtil.getAddresses(_serverString)); } } catch (IOException error) { throw(new KeyValueStoreClientException(error)); } return true; }