@Test void put_nullCacheValueWithDefaultExpiration_keyStoredInCache() throws Exception { MemcachedClientIF client = mock(MemcachedClientIF.class); SimpleSpringMemcached cache = new SimpleSpringMemcached(client, "test"); when(client.set("test", 0, null)).thenReturn(new AsyncResult<>(true)); cache.put("test", null); verify(client, times(1)).set("test", 0, null); }
@Override public void put(Object key, Object value) { Assert.notNull(key, "key parameter is mandatory"); Assert.isAssignable(String.class, key.getClass()); try { this.memcachedClientIF.set((String) key, this.expiration, value).get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (ExecutionException e) { throw new IllegalArgumentException("Error writing key" + key, e); } }
SimpleSpringMemcached implements Cache { @Override public void put(Object key, Object value) { Assert.notNull(key, "key parameter is mandatory"); Assert.isAssignable(String.class, key.getClass()); try { this.memcachedClientIF.set((String) key, this.expiration, value).get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (ExecutionException e) { throw new IllegalArgumentException("Error writing key" + key, e); } } }
SimpleSpringMemcached implements Cache { @Override public void put(Object key, Object value) { Assert.notNull(key, "key parameter is mandatory"); Assert.isAssignable(String.class, key.getClass()); try { this.memcachedClientIF.set((String) key, this.expiration, value).get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (ExecutionException e) { throw new IllegalArgumentException("Error writing key" + key, e); } } SimpleSpringMemcached(MemcachedClientIF memcachedClientIF, String cacheName); }
SimpleSpringMemcached implements Cache { @Override public void put(Object key, Object value) { Assert.notNull(key, "key parameter is mandatory"); Assert.isAssignable(String.class, key.getClass()); try { this.memcachedClientIF.set((String) key, this.expiration, value).get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (ExecutionException e) { throw new IllegalArgumentException("Error writing key" + key, e); } } SimpleSpringMemcached(MemcachedClientIF memcachedClientIF, String cacheName); @Override String getName(); @Override Object getNativeCache(); @Override ValueWrapper get(Object key); @Override T get(Object key, Class<T> type); @SuppressWarnings("unchecked") @Override T get(Object key, Callable<T> valueLoader); @Override void put(Object key, Object value); @Override ValueWrapper putIfAbsent(Object key, Object value); @Override void evict(Object key); @Override void clear(); void setExpiration(int expiration); }
SimpleSpringMemcached implements Cache { @Override public void put(Object key, Object value) { Assert.notNull(key, "key parameter is mandatory"); Assert.isAssignable(String.class, key.getClass()); try { this.memcachedClientIF.set((String) key, this.expiration, value).get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (ExecutionException e) { throw new IllegalArgumentException("Error writing key" + key, e); } } SimpleSpringMemcached(MemcachedClientIF memcachedClientIF, String cacheName); @Override String getName(); @Override Object getNativeCache(); @Override ValueWrapper get(Object key); @Override T get(Object key, Class<T> type); @SuppressWarnings("unchecked") @Override T get(Object key, Callable<T> valueLoader); @Override void put(Object key, Object value); @Override ValueWrapper putIfAbsent(Object key, Object value); @Override void evict(Object key); @Override void clear(); void setExpiration(int expiration);  }