Class EntityMemcache.Bucket

  • Enclosing class:
    EntityMemcache

    public class EntityMemcache.Bucket
    extends Object
    A bucket represents memcache information for a particular Key. It might have an entity, it might be a negative cache result, it might be empty. Buckets can be hash keys; they hash to their Key value.
    • Constructor Summary

      Constructors 
      Constructor Description
      Bucket​(com.google.cloud.datastore.Key key)
      Crate a bucket with an uncacheable key.
      Bucket​(com.google.cloud.datastore.Key key, IdentifiableValue identifiableValue)  
    • Constructor Detail

      • Bucket

        public Bucket​(com.google.cloud.datastore.Key key)
        Crate a bucket with an uncacheable key. Same as this(key, null).
      • Bucket

        public Bucket​(com.google.cloud.datastore.Key key,
                      IdentifiableValue identifiableValue)
        Parameters:
        identifiableValue - can be null to indicate an uncacheable key
    • Method Detail

      • getKey

        public com.google.cloud.datastore.Key getKey()
      • isCacheable

        public boolean isCacheable()
        Returns:
        true if we can cache this bucket; false if the key isn't cacheable or the memcache was down when we created the bucket
      • isNegative

        public boolean isNegative()
        Returns:
        true if this is a negative cache result
      • isEmpty

        public boolean isEmpty()
        "Empty" means we don't know the value - it could be null, it could be uncacheable, or we could have some really weird unknown data in the cache. Basically, anything other than "yes we have an entity/negative" is considered empty.
        Returns:
        true if this is empty or uncacheable or something other than a nice entity or negative result.
      • getEntity

        public com.google.cloud.datastore.Entity getEntity()
        Get the entity stored at this bucket, possibly the one that was set
      • setNext

        public void setNext​(com.google.cloud.datastore.Entity value)
        Prepare the value that will be set in memcache in the next putAll(). Null (or not calling this method) will put a negative result in the cache.