Package org.casbin.jcasbin.persist.cache
Class DefaultCache
java.lang.Object
org.casbin.jcasbin.persist.cache.DefaultCache
- All Implemented Interfaces:
Cache
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear the entire cache.void
Delete the value from the cache.boolean
Get the value from the cache, handling expiration.void
Set the cache value without a TTL.boolean
Set puts key and value into cache.void
Set the cache value with an optional time-to-live (TTL).
-
Field Details
-
cache
-
-
Constructor Details
-
DefaultCache
public DefaultCache()
-
-
Method Details
-
set
Set the cache value with an optional time-to-live (TTL).- Parameters:
key
- The cache key to store the value.value
- The boolean value to be stored in the cache.ttl
- The time-to-live for the cache item; if null or negative, the item will not expire.
-
set
Set the cache value without a TTL.- Parameters:
key
- The cache key to store the value.value
- The boolean value to be stored in the cache.
-
set
Set puts key and value into cache. The first extra parameter should be a java.time.LocalDateTime object denoting the expected survival time. If survival time equals 0 or less, the key will always be valid. -
get
Get the value from the cache, handling expiration.- Specified by:
get
in interfaceCache
- Parameters:
key
- The cache key to retrieve the value.- Returns:
- The value corresponding to the key.
- Throws:
CasbinCacheException
- If the key does not exist in the cache.
-
delete
Delete the value from the cache.- Specified by:
delete
in interfaceCache
- Parameters:
key
- The cache key to delete the value.- Throws:
CasbinCacheException
-
clear
public void clear()Clear the entire cache.
-