@Test public void testDelete() { Datastore datastore = getService(); KeyFactory keyFactory = datastore.newKeyFactory().setKind(CACHE_KIND); Key key = keyFactory.newKey("test"); Entity.Builder builder = Entity.newBuilder(key); builder.set(CACHE_VALUE_FIELD, BlobValue.of(Blob.copyFrom("abcd".getBytes()))); builder.set(CACHE_EXPIRY_FIELD, 0); Entity entity = builder.build(); datastore.put(entity); cache.delete("test"); assertNull(cache.get("test")); }
@Override public void delete(String key) { Datastore datastore = getService(); KeyFactory keyFactory = datastore.newKeyFactory().setKind(CACHE_KIND); Key datastoreKey = keyFactory.newKey(key); datastore.delete(datastoreKey); }
CloudDatastoreCache extends AbstractRemoteCache { @Override public void delete(String key) { Datastore datastore = getService(); KeyFactory keyFactory = datastore.newKeyFactory().setKind(CACHE_KIND); Key datastoreKey = keyFactory.newKey(key); datastore.delete(datastoreKey); } }
CloudDatastoreCache extends AbstractRemoteCache { @Override public void delete(String key) { Datastore datastore = getService(); KeyFactory keyFactory = datastore.newKeyFactory().setKind(CACHE_KIND); Key datastoreKey = keyFactory.newKey(key); datastore.delete(datastoreKey); }  }
CloudDatastoreCache extends AbstractRemoteCache { @Override public void delete(String key) { Datastore datastore = getService(); KeyFactory keyFactory = datastore.newKeyFactory().setKind(CACHE_KIND); Key datastoreKey = keyFactory.newKey(key); datastore.delete(datastoreKey); }  @Override byte[] get(String key); @Override void set(String key, byte[] value); @Override void set(String key, byte[] value, int expireIn); @Override void delete(String key); int deleteExpiredItems(); int deleteExpiredItems(Integer limit); @Override Lock acquireLock(String lockName); @Override CheckResult checkConnection(); }
CloudDatastoreCache extends AbstractRemoteCache { @Override public void delete(String key) { Datastore datastore = getService(); KeyFactory keyFactory = datastore.newKeyFactory().setKind(CACHE_KIND); Key datastoreKey = keyFactory.newKey(key); datastore.delete(datastoreKey); }  @Override byte[] get(String key); @Override void set(String key, byte[] value); @Override void set(String key, byte[] value, int expireIn); @Override void delete(String key); int deleteExpiredItems(); int deleteExpiredItems(Integer limit); @Override Lock acquireLock(String lockName); @Override CheckResult checkConnection(); final static String CACHE_KIND; final static String CACHE_VALUE_FIELD; final static String CACHE_EXPIRY_FIELD; }