类 SimpleProxyCache<K,V>

java.lang.Object
com.alicp.jetcache.SimpleProxyCache<K,V>
所有已实现的接口:
Cache<K,V>, ProxyCache<K,V>, Closeable, AutoCloseable
直接已知子类:
LoadingCache

public class SimpleProxyCache<K,V> extends Object implements ProxyCache<K,V>
Created on 2017/5/17.
作者:
huangli
  • 字段概要

    从接口继承的字段 com.alicp.jetcache.Cache

    logger
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    Clean resources created by this cache.
    computeIfAbsent(K key, Function<K,V> loader)
    If there is a value associated with the key, return the value; otherwise use the loader load the value and return, and then update the cache.
    computeIfAbsent(K key, Function<K,V> loader, boolean cacheNullWhenLoaderReturnNull)
    If there is a value associated with the key, return the value; otherwise use the loader load the value and return, and then update the cache.
    computeIfAbsent(K key, Function<K,V> loader, boolean cacheNullWhenLoaderReturnNull, long expireAfterWrite, TimeUnit timeUnit)
    If there is a value associated with the key, return the value; otherwise use the loader load the value and return, and then update the cache.
    Get the config of this cache.
    get(K key)
    Gets an entry from the cache.
    GET(K key)
    Gets an entry from the cache.
    GET_ALL(Set<? extends K> keys)
    Gets a collection of entries from the Cache.
    getAll(Set<? extends K> keys)
    Gets a collection of entries from the Cache, returning them as Map of the values associated with the set of keys requested.
     
    void
    put(K key, V value)
    Associates the specified value with the specified key in the cache.
    void
    put(K key, V value, long expireAfterWrite, TimeUnit timeUnit)
    Associates the specified value with the specified key in the cache.
    PUT(K key, V value)
    Associates the specified value with the specified key in the cache.
    PUT(K key, V value, long expireAfterWrite, TimeUnit timeUnit)
    Associates the specified value with the specified key in the cache.
    PUT_ALL(Map<? extends K,? extends V> map)
    Copies all of the entries from the specified map to the cache.
    PUT_ALL(Map<? extends K,? extends V> map, long expireAfterWrite, TimeUnit timeUnit)
    Copies all of the entries from the specified map to the cache.
    PUT_IF_ABSENT(K key, V value, long expireAfterWrite, TimeUnit timeUnit)
    If the specified key is not already associated with a value, associate it with the given value.
    void
    putAll(Map<? extends K,? extends V> map)
    Copies all of the entries from the specified map to the cache.
    void
    putAll(Map<? extends K,? extends V> map, long expireAfterWrite, TimeUnit timeUnit)
    Copies all of the entries from the specified map to the cache.
    boolean
    putIfAbsent(K key, V value)
    Atomically associates the specified key with the given value if it is not already associated with a value.
    boolean
    remove(K key)
    Removes the mapping for a key from this cache if it is present.
    REMOVE(K key)
    Removes the mapping for a key from this cache if it is present.
    REMOVE_ALL(Set<? extends K> keys)
    Removes entries for the specified keys.
    void
    removeAll(Set<? extends K> keys)
    Removes entries for the specified keys.
    tryLock(K key, long expire, TimeUnit timeUnit)
    Use this cache attempt to acquire a exclusive lock specified by the key, this method will not block.
    boolean
    tryLockAndRun(K key, long expire, TimeUnit timeUnit, Runnable action)
    Use this cache to try run an action exclusively.
    <T> T
    unwrap(Class<T> clazz)
    Provides a standard way to access the underlying concrete cache entry implementation in order to provide access to further, proprietary features.

    从类继承的方法 java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • SimpleProxyCache

      public SimpleProxyCache(Cache<K,V> cache)
  • 方法详细资料

    • config

      public CacheConfig<K,V> config()
      从接口复制的说明: Cache
      Get the config of this cache.
      指定者:
      config 在接口中 Cache<K,V>
      返回:
      the cache config
    • getTargetCache

      public Cache<K,V> getTargetCache()
      指定者:
      getTargetCache 在接口中 ProxyCache<K,V>
    • get

      public V get(K key)
      从接口复制的说明: Cache
      Gets an entry from the cache.

      If the cache's builder has specified a CacheLoader and there is no association in the cache , it will attempt to load the entry.

      If error occurs during cache access, the method return null instead of throwing an exception.

      指定者:
      get 在接口中 Cache<K,V>
      参数:
      key - the key whose associated value is to be returned
      返回:
      the associated value. null may indicates:
      • the entry does not exist or expired
      • the entry value is null
      • error occurs during cache access(no exception throws)
      另请参阅:
    • getAll

      public Map<K,V> getAll(Set<? extends K> keys)
      从接口复制的说明: Cache
      Gets a collection of entries from the Cache, returning them as Map of the values associated with the set of keys requested.

      If the cache's builder has specified a CacheLoader and there is no association in the cache , it will attempt to load the entry.

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

      指定者:
      getAll 在接口中 Cache<K,V>
      参数:
      keys - The keys whose associated values are to be returned.
      返回:
      A map of entries that were found for the given keys. Keys not found in the cache are not in the returned map.
      另请参阅:
    • put

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

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

      if the implementation supports asynchronous operation, the cache operation of this method is asynchronous.

      指定者:
      put 在接口中 Cache<K,V>
      参数:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
      另请参阅:
    • putAll

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

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

      if the implementation supports asynchronous operation, the cache operation of this method is asynchronous.

      指定者:
      putAll 在接口中 Cache<K,V>
      参数:
      map - mappings to be stored in this cache.
      另请参阅:
    • 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.

      指定者:
      putIfAbsent 在接口中 Cache<K,V>
      参数:
      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.
      另请参阅:
    • remove

      public boolean remove(K key)
      从接口复制的说明: Cache
      Removes the mapping for a key from this cache if it is present.

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

      指定者:
      remove 在接口中 Cache<K,V>
      参数:
      key - key whose mapping is to be removed from the cache
      返回:
      true if the key is removed successfully, false if the KV association does not exists in the cache, or error occurs during cache access.
      另请参阅:
    • removeAll

      public void removeAll(Set<? extends K> keys)
      从接口复制的说明: Cache
      Removes entries for the specified keys.

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

      if the implementation supports asynchronous operation, the cache operation of this method is asynchronous.

      指定者:
      removeAll 在接口中 Cache<K,V>
      参数:
      keys - the keys to remove
      另请参阅:
    • 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.

      指定者:
      unwrap 在接口中 Cache<K,V>
      指定者:
      unwrap 在接口中 ProxyCache<K,V>
      参数:
      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.

      指定者:
      tryLock 在接口中 Cache<K,V>
      参数:
      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.
      另请参阅:
    • tryLockAndRun

      public boolean tryLockAndRun(K key, long expire, TimeUnit timeUnit, Runnable action)
      从接口复制的说明: Cache
      Use this cache to try run an action exclusively.

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

      examples:
       cache.tryLock("MyKey",100, TimeUnit.SECONDS),() -> {
           //do something
       });
       
      指定者:
      tryLockAndRun 在接口中 Cache<K,V>
      参数:
      key - lockKey
      expire - lock expire time
      timeUnit - lock expire time unit
      action - the action need to execute
      返回:
      true if successfully get the lock and the action is executed
    • GET

      public CacheGetResult<V> GET(K key)
      从接口复制的说明: Cache
      Gets an entry from the cache.

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

      指定者:
      GET 在接口中 Cache<K,V>
      参数:
      key - the key
      返回:
      the result
    • GET_ALL

      public MultiGetResult<K,V> GET_ALL(Set<? extends K> keys)
      从接口复制的说明: Cache
      Gets a collection of entries from the Cache.

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

      指定者:
      GET_ALL 在接口中 Cache<K,V>
      参数:
      keys - the key collection
      返回:
      the result
    • computeIfAbsent

      public V computeIfAbsent(K key, Function<K,V> loader)
      从接口复制的说明: Cache
      If there is a value associated with the key, return the value; otherwise use the loader load the value and return, and then update the cache.
      指定者:
      computeIfAbsent 在接口中 Cache<K,V>
      参数:
      key - the key
      loader - the value loader
      返回:
      the value
      另请参阅:
    • computeIfAbsent

      public V computeIfAbsent(K key, Function<K,V> loader, boolean cacheNullWhenLoaderReturnNull)
      从接口复制的说明: Cache
      If there is a value associated with the key, return the value; otherwise use the loader load the value and return, and then update the cache.
      指定者:
      computeIfAbsent 在接口中 Cache<K,V>
      参数:
      key - the key
      loader - the value loader
      cacheNullWhenLoaderReturnNull - true if null value returned by loader should put into cache use the key
      返回:
      the value
    • computeIfAbsent

      public V computeIfAbsent(K key, Function<K,V> loader, boolean cacheNullWhenLoaderReturnNull, long expireAfterWrite, TimeUnit timeUnit)
      从接口复制的说明: Cache
      If there is a value associated with the key, return the value; otherwise use the loader load the value and return, and then update the cache.
      指定者:
      computeIfAbsent 在接口中 Cache<K,V>
      参数:
      key - the key
      loader - the value loader
      cacheNullWhenLoaderReturnNull - true if null value returned by loader should put into cache use the key
      expireAfterWrite - the TTL(time to live) of the KV association
      timeUnit - the time unit of expireAfterWrite
      返回:
      the value
    • put

      public void put(K key, V value, long expireAfterWrite, TimeUnit timeUnit)
      从接口复制的说明: Cache
      Associates the specified value with the specified key in the cache.

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

      指定者:
      put 在接口中 Cache<K,V>
      参数:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
      expireAfterWrite - the TTL(time to live) of the KV association
      timeUnit - the time unit of expireAfterWrite
      另请参阅:
    • 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.

      指定者:
      PUT 在接口中 Cache<K,V>
      参数:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
      返回:
      the result
    • PUT

      public CacheResult PUT(K key, V value, long expireAfterWrite, TimeUnit timeUnit)
      从接口复制的说明: 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.

      指定者:
      PUT 在接口中 Cache<K,V>
      参数:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
      expireAfterWrite - the TTL(time to live) of the KV association
      timeUnit - the time unit of expireAfterWrite
      返回:
      the result
    • putAll

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

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

      指定者:
      putAll 在接口中 Cache<K,V>
      参数:
      map - mappings to be stored in this cache.
      expireAfterWrite - the TTL(time to live) of the KV association
      timeUnit - the time unit of expireAfterWrite
      另请参阅:
    • 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.

      指定者:
      PUT_ALL 在接口中 Cache<K,V>
      参数:
      map - mappings to be stored in this cache.
      返回:
      the result
    • PUT_ALL

      public CacheResult PUT_ALL(Map<? extends K,? extends V> map, long expireAfterWrite, TimeUnit timeUnit)
      从接口复制的说明: 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.

      指定者:
      PUT_ALL 在接口中 Cache<K,V>
      参数:
      map - mappings to be stored in this cache.
      expireAfterWrite - the TTL(time to live) of the KV association
      timeUnit - the time unit of expireAfterWrite
      返回:
      the result
    • REMOVE

      public CacheResult REMOVE(K key)
      从接口复制的说明: Cache
      Removes the mapping for a key from this cache if it is present.

      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.

      指定者:
      REMOVE 在接口中 Cache<K,V>
      参数:
      key - key whose mapping is to be removed from the cache
      返回:
      the result
    • REMOVE_ALL

      public CacheResult REMOVE_ALL(Set<? extends K> keys)
      从接口复制的说明: Cache
      Removes entries for the specified keys.

      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.

      指定者:
      REMOVE_ALL 在接口中 Cache<K,V>
      参数:
      keys - the keys to remove
      返回:
      the result
    • PUT_IF_ABSENT

      public CacheResult PUT_IF_ABSENT(K key, V value, long expireAfterWrite, TimeUnit timeUnit)
      从接口复制的说明: Cache
      If the specified key is not already associated with a value, associate it with the given value.

      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.

      指定者:
      PUT_IF_ABSENT 在接口中 Cache<K,V>
      参数:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
      expireAfterWrite - the TTL(time to live) of the KV association
      timeUnit - the time unit of expireAfterWrite
      返回:
      SUCCESS if the specified key is not already associated with a value, or EXISTS if the specified key is already associated with a value, or FAIL if error occurs.
    • close

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