public class CachingAsyncTransaction extends CachingAsyncDatastoreReaderWriter implements PrivateAsyncTransaction
A write-through memcache for Entity objects that works for both transactional and nontransactional sessions.
Note: Until Google adds a hook that lets us wrap native Future> implementations,
you muse install the AsyncCacheFilter
to use this cache asynchronously. This
is not necessary for synchronous use of CachingDatastoreService
, but asynchronous
operation requires an extra hook for the end of a request when fired-and-forgotten put()s
and delete()s get processed. If you use this cache asynchronously, and you do not
use the AsyncCacheFilter
, your cache will go out of sync.
Constructor and Description |
---|
CachingAsyncTransaction(AsyncTransaction raw,
EntityMemcache memcache) |
Modifier and Type | Method and Description |
---|---|
com.google.cloud.datastore.Transaction.Response |
commit() |
Future<Void> |
delete(Iterable<com.google.cloud.datastore.Key> keys) |
protected void |
empty(Iterable<com.google.cloud.datastore.Key> keys) |
void |
enlist(Result<?> result) |
Future<Map<com.google.cloud.datastore.Key,com.google.cloud.datastore.Entity>> |
get(com.google.cloud.datastore.Key... keys)
Odd that this is array and the others are iterable, but that's how the underlying API is
|
boolean |
isActive() |
void |
listenForCommit(Runnable listener) |
Future<List<com.google.cloud.datastore.Key>> |
put(Iterable<? extends com.google.cloud.datastore.FullEntity<?>> entities) |
void |
rollback() |
<T> com.google.cloud.datastore.QueryResults<T> |
run(com.google.cloud.datastore.Query<T> query) |
void |
runCommitListeners() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
get, put
public CachingAsyncTransaction(AsyncTransaction raw, EntityMemcache memcache)
protected void empty(Iterable<com.google.cloud.datastore.Key> keys)
empty
in class CachingAsyncDatastoreReaderWriter
public com.google.cloud.datastore.Transaction.Response commit()
commit
in interface AsyncTransaction
public boolean isActive()
isActive
in interface AsyncTransaction
public void rollback()
rollback
in interface AsyncTransaction
public void listenForCommit(Runnable listener)
listenForCommit
in interface AsyncTransaction
public void runCommitListeners()
runCommitListeners
in interface PrivateAsyncTransaction
public void enlist(Result<?> result)
enlist
in interface PrivateAsyncTransaction
public Future<Void> delete(Iterable<com.google.cloud.datastore.Key> keys)
delete
in interface AsyncDatastoreReaderWriter
delete
in class CachingAsyncDatastoreReaderWriter
public Future<Map<com.google.cloud.datastore.Key,com.google.cloud.datastore.Entity>> get(com.google.cloud.datastore.Key... keys)
AsyncDatastoreReaderWriter
get
in interface AsyncDatastoreReaderWriter
public <T> com.google.cloud.datastore.QueryResults<T> run(com.google.cloud.datastore.Query<T> query)
run
in interface AsyncDatastoreReaderWriter
run
in class CachingAsyncDatastoreReaderWriter
public Future<List<com.google.cloud.datastore.Key>> put(Iterable<? extends com.google.cloud.datastore.FullEntity<?>> entities)
put
in interface AsyncDatastoreReaderWriter
put
in class CachingAsyncDatastoreReaderWriter
Copyright © 2017. All rights reserved.