类 MultiLevelCache<K,V>

java.lang.Object
com.alicp.jetcache.AbstractCache<K,V>
com.alicp.jetcache.MultiLevelCache<K,V>
所有已实现的接口:
Cache<K,V>, Closeable, AutoCloseable

public class MultiLevelCache<K,V> extends AbstractCache<K,V>
Created on 16/9/13.
作者:
huangli
  • 构造器详细资料

  • 方法详细资料

    • caches

      public Cache[] caches()
    • config

      public MultiLevelCacheConfig<K,V> config()
      从接口复制的说明: Cache
      Get the config of this cache.
      返回:
      the cache config
    • PUT

      public CacheResult PUT(K key, V value)
      从接口复制的说明: Cache
      Associates the specified value with the specified key in the cache.

      if the implementation supports asynchronous operation, the cache access may not completed after this method return. The invoke of getResultCode()/isSuccess()/getMessage() on the result will block until cache operation is completed. Call future() method on the result will get a CompletionStage instance for asynchronous programming.

      参数:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
      返回:
      the result
    • PUT_ALL

      public CacheResult PUT_ALL(Map<? extends K,? extends V> map)
      从接口复制的说明: Cache
      Copies all of the entries from the specified map to the cache.

      if the implementation supports asynchronous operation, the cache access may not completed after this method return. The invoke of getResultCode()/isSuccess()/getMessage() on the result will block until cache operation is completed. Call future() method on the result will get a CompletionStage instance for asynchronous programming.

      参数:
      map - mappings to be stored in this cache.
      返回:
      the result
    • unwrap

      public <T> T unwrap(Class<T> clazz)
      从接口复制的说明: Cache
      Provides a standard way to access the underlying concrete cache entry implementation in order to provide access to further, proprietary features.

      If the implementation does not support the specified class, the IllegalArgumentException is thrown.

      参数:
      clazz - the proprietary class or interface of the underlying concrete cache. It is this type that is returned.
      返回:
      an instance of the underlying concrete cache
    • tryLock

      public AutoReleaseLock tryLock(K key, long expire, TimeUnit timeUnit)
      从接口复制的说明: Cache
      Use this cache attempt to acquire a exclusive lock specified by the key, this method will not block. examples:
         try(AutoReleaseLock lock = cache.tryLock("MyKey",100, TimeUnit.SECONDS)){
            if(lock != null){
                // do something
            }
         }
       

      MultiLevelCache will use the last level cache to support this operation.

      参数:
      key - lockKey
      expire - lock expire time
      timeUnit - lock expire time unit
      返回:
      an AutoReleaseLock(implements java.lang.AutoCloseable) instance if success. or null if the attempt fails, which indicates there is an another thread/process/server has the lock, or error occurs during cache access.
      另请参阅:
    • putIfAbsent

      public boolean putIfAbsent(K key, V value)
      从接口复制的说明: Cache
      Atomically associates the specified key with the given value if it is not already associated with a value.

      If error occurs during cache access, the method will not throw an exception.

      MultiLevelCache does not support this method.

      参数:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
      返回:
      true if a value was set, false if the KV association does not exists in the cache, or error occurs during cache access.
      另请参阅:
    • close

      public void close()
      从接口复制的说明: Cache
      Clean resources created by this cache.
      指定者:
      close 在接口中 AutoCloseable
      指定者:
      close 在接口中 Cache<K,V>
      指定者:
      close 在接口中 Closeable
      覆盖:
      close 在类中 AbstractCache<K,V>