Skip to content

Instantly share code, notes, and snippets.

@jclouds
Created May 15, 2012 06:29
Show Gist options
  • Save jclouds/2699578 to your computer and use it in GitHub Desktop.
Save jclouds/2699578 to your computer and use it in GitHub Desktop.
example CacheLoader that works around eventual consistency delay between bucket creation and bucket ACL access
CacheLoader<String, AccessControlList> loader = RetryingCacheLoaderDecorator.newDecorator()
.on(ResourceNotFoundException.class).exponentiallyBackoff()
.decorate(
new CacheLoader<String, AccessControlList>() {
@Override
public AccessControlList load(String bucketName) {
return client.getBucketACL(bucketName);
}
@Override
public String toString() {
return "getBucketAcl()";
}
});
return CacheBuilder.newBuilder().expireAfterWrite(30, TimeUnit.SECONDS).build(loader);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment