Skip to content

1.0.1 ETagManager

Anders Mikkelsen edited this page Dec 15, 2017 · 4 revisions

ETagManager

The ETagManager interface is used to manage etags. This can be passed into certain implementations of the Repository interface for automatically updating etags on mutable operations or it can be used standalone. It only accepts objects which implement both Method and ETagable interfaces.

The interface looks like this:

public interface ETagManager<E extends Model & ETagable> {
    void removeProjectionsEtags(int hash, Handler<AsyncResult<Boolean>> resultHandler);
    void destroyEtags(int hash, Handler<AsyncResult<Boolean>> resultHandler);
    void replaceAggregationEtag(String etagItemListHashKey, String etagKey, String newEtag,
                                Handler<AsyncResult<Boolean>> resultHandler);

    void setSingleRecordEtag(Map<String, String> etagMap, Handler<AsyncResult<Boolean>> resultHandler);
    void setProjectionEtags(String[] projections, int hash, E item);
    void setItemListEtags(String etagItemListHashKey, String etagKey, ItemList<E> itemList, Future<Boolean> itemListEtagFuture);

    void checkItemEtag(String etagKeyBase, String key, String requestEtag, Handler<AsyncResult<Boolean>> resultHandler);
    void checkItemListEtag(String etagItemListHashKey, String etagKey, String etag, Handler<AsyncResult<Boolean>> resultHandler);
    void checkAggregationEtag(String etagItemListHashKey, String etagKey, String etag, Handler<AsyncResult<Boolean>> resultHandler);
}

Implementations

nannoq-repository comes with two premade ETagManagers, InMemoryEtagManagerImpl and RedisETagManagerImpl.

InMemoryEtagManagerImpl

This leverages the sharedData structure of Vertx. It uses a LocalMap if vertx is not clustered and a distributed AsyncMap if vert is clustered. This means multiple objects will access the same maps.

RedisETagManagerImpl

This leverages an external Redis store.