@Test(dataProvider = "getData") public void get(String prefix, boolean readOnly, String key, String memcacheKey, CachedResponse response) { MemcachedClient client = mock(MemcachedClient.class); MemcachedResponseStore store = new MemcachedResponseStore(client, prefix, readOnly); when(client.get(eq(memcacheKey), any(Transcoder.class))).thenReturn(response); Optional<CachedResponse> getResponse = store.get(key); if (response == null) { assertFalse(getResponse.isPresent()); } else { assertSame(getResponse.get(), response); } verify(client).get(eq(memcacheKey), any(Transcoder.class)); }
@Override public Optional<CachedResponse> get(String key) { checkNotNull(key); checkArgument(key.length() > 0, "key can not be empty"); return Optional.fromNullable(_client.get(buildKey(key), CachedResponseTranscoder.INSTANCE)); }
MemcachedResponseStore extends ResponseStore { @Override public Optional<CachedResponse> get(String key) { checkNotNull(key); checkArgument(key.length() > 0, "key can not be empty"); return Optional.fromNullable(_client.get(buildKey(key), CachedResponseTranscoder.INSTANCE)); } }
MemcachedResponseStore extends ResponseStore { @Override public Optional<CachedResponse> get(String key) { checkNotNull(key); checkArgument(key.length() > 0, "key can not be empty"); return Optional.fromNullable(_client.get(buildKey(key), CachedResponseTranscoder.INSTANCE)); } MemcachedResponseStore(MemcachedClient client, String keyPrefix, boolean readOnly); }
MemcachedResponseStore extends ResponseStore { @Override public Optional<CachedResponse> get(String key) { checkNotNull(key); checkArgument(key.length() > 0, "key can not be empty"); return Optional.fromNullable(_client.get(buildKey(key), CachedResponseTranscoder.INSTANCE)); } MemcachedResponseStore(MemcachedClient client, String keyPrefix, boolean readOnly); @Override Optional<CachedResponse> get(String key); @Override void put(String key, CachedResponse response); @Override void invalidate(String key); }
MemcachedResponseStore extends ResponseStore { @Override public Optional<CachedResponse> get(String key) { checkNotNull(key); checkArgument(key.length() > 0, "key can not be empty"); return Optional.fromNullable(_client.get(buildKey(key), CachedResponseTranscoder.INSTANCE)); } MemcachedResponseStore(MemcachedClient client, String keyPrefix, boolean readOnly); @Override Optional<CachedResponse> get(String key); @Override void put(String key, CachedResponse response); @Override void invalidate(String key);  }