Package io.mangoo.cache
Interface Cache
- All Known Implementing Classes:
CacheImpl
public interface Cache
- Author:
- svenkubiak
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the complete cache by invalidating all entries<T> TRetrieves an object from the caches and converts it to a given classDecrements a counter with a given key If the counter did not exist, it will be created and the decrementedIncrements a cache counter with a given key If the counter did not exist, it will be created and the incrementedgetCounter(String key) Retrieves the counter for a given keyvoidAdds a value to cache with a given key overwriting and existing valuevoidAdds a complete map of objects to the cachevoidRemoves a value with a given key from the cacheresetCounter(String key) Resets the counter for a given key
-
Method Details
-
put
Adds a value to cache with a given key overwriting and existing value- Parameters:
key- The key for the cached valuevalue- The value to store
-
remove
Removes a value with a given key from the cache- Parameters:
key- The key for the cached value
-
clear
void clear()Clears the complete cache by invalidating all entries -
get
Retrieves an object from the caches and converts it to a given class- Type Parameters:
T- JavaDoc requires this (just ignore it)- Parameters:
key- The key for the cached value- Returns:
- A converted cache class value
-
putAll
Adds a complete map of objects to the cache- Parameters:
map- The map to add
-
getAndIncrementCounter
Increments a cache counter with a given key If the counter did not exist, it will be created and the incremented- Parameters:
key- The key for the cached value- Returns:
- A counter based on AtomicInteger
-
getAndDecrementCounter
Decrements a counter with a given key If the counter did not exist, it will be created and the decremented- Parameters:
key- The key for the cached value- Returns:
- A counter based on AtomicInteger
-
getCounter
Retrieves the counter for a given key- Parameters:
key- The key for the counter- Returns:
- A counter based on AtomicInteger or null if none found
-
resetCounter
Resets the counter for a given key- Parameters:
key- The key for the counter- Returns:
- A counter based on AtomicInteger
-