Package io.mangoo.cache
Interface Cache
-
- All Known Implementing Classes:
CacheImpl
public interface Cache- Author:
- svenkubiak
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclear()Clears the complete cache by invalidating all entries<T> Tget(String key)Retrieves an object from the caches and converts it to a given classAtomicIntegergetAndDecrementCounter(String key)Decrements a counter with a given key If the counter does not exists, it will be created and the decrementedAtomicIntegergetAndIncrementCounter(String key)Increments a cache counter with a given key If the counter does not exists, it will be created and the incrementedAtomicIntegergetCounter(String key)Retrieves the counter for a given keyvoidput(String key, Object value)Adds a value to cache with a given key overwriting and existing valuevoidputAll(Map<String,Object> map)Adds a complete map of objects to the cachevoidremove(String key)Removes a value with a given key from the cacheAtomicIntegerresetCounter(String key)Resets the counter for a given key
-
-
-
Method Detail
-
put
void put(String key, Object value)
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
void remove(String key)
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
<T> T get(String key)
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
void putAll(Map<String,Object> map)
Adds a complete map of objects to the cache- Parameters:
map- The map to add
-
getAndIncrementCounter
AtomicInteger getAndIncrementCounter(String key)
Increments a cache counter with a given key If the counter does not exists, it will be created and the incremented- Parameters:
key- The key for the cached value- Returns:
- A counter based on AtomicInteger
-
getAndDecrementCounter
AtomicInteger getAndDecrementCounter(String key)
Decrements a counter with a given key If the counter does not exists, it will be created and the decremented- Parameters:
key- The key for the cached value- Returns:
- A counter based on AtomicInteger
-
getCounter
AtomicInteger getCounter(String key)
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
AtomicInteger resetCounter(String key)
Resets the counter for a given key- Parameters:
key- The key for the counter- Returns:
- A counter based on AtomicInteger
-
-