Package io.github.dhruv1110.jcachex.impl
Class UltraFastCache<K,V>
- java.lang.Object
-
- io.github.dhruv1110.jcachex.impl.UltraFastCache<K,V>
-
- All Implemented Interfaces:
Cache<K,V>
public final class UltraFastCache<K,V> extends Object implements Cache<K,V>
Ultra-fast cache implementation optimized for maximum throughput. Key optimizations: - Minimal hot path overhead - Lock-free operations where possible - Efficient eviction with O(1) operations - Reduced object allocation - Optimized for CPU cache efficiency
-
-
Constructor Summary
Constructors Constructor Description UltraFastCache(CacheConfig<K,V> config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Removes all mappings from this cache.CompletableFuture<Void>clearAsync()Asynchronously removes all mappings from this cache.CacheConfig<K,V>config()Returns the cache configuration.booleancontainsKey(K key)Returns true if this cache contains a mapping for the specified key.Set<Map.Entry<K,V>>entries()Returns a view of all the key-value pairs in this cache.Vget(K key)Ultra-fast get operation with minimal overhead.CompletableFuture<V>getAsync(K key)Asynchronously returns the value associated with the key in this cache.Set<K>keys()Returns a view of all the keys in this cache.voidput(K key, V value)Ultra-fast put operation with efficient eviction.CompletableFuture<Void>putAsync(K key, V value)Asynchronously associates the specified value with the specified key in this cache.Vremove(K key)Removes the mapping for a key from this cache if it is present.CompletableFuture<V>removeAsync(K key)Asynchronously removes the mapping for a key from this cache if it is present.longsize()Returns the approximate number of entries in this cache.CacheStatsstats()Returns the cache statistics.Collection<V>values()Returns a view of all the values in this cache.
-
-
-
Constructor Detail
-
UltraFastCache
public UltraFastCache(CacheConfig<K,V> config)
-
-
Method Detail
-
remove
public V remove(K key)
Description copied from interface:CacheRemoves the mapping for a key from this cache if it is present.
-
clear
public void clear()
Description copied from interface:CacheRemoves all mappings from this cache.
-
size
public long size()
Description copied from interface:CacheReturns the approximate number of entries in this cache.
-
containsKey
public boolean containsKey(K key)
Description copied from interface:CacheReturns true if this cache contains a mapping for the specified key.- Specified by:
containsKeyin interfaceCache<K,V>- Parameters:
key- key whose presence in this cache is to be tested- Returns:
- true if this cache contains a mapping for the specified key
-
keys
public Set<K> keys()
Description copied from interface:CacheReturns a view of all the keys in this cache.
-
values
public Collection<V> values()
Description copied from interface:CacheReturns a view of all the values in this cache.
-
entries
public Set<Map.Entry<K,V>> entries()
Description copied from interface:CacheReturns a view of all the key-value pairs in this cache.
-
stats
public CacheStats stats()
Description copied from interface:CacheReturns the cache statistics.
-
config
public CacheConfig<K,V> config()
Description copied from interface:CacheReturns the cache configuration.
-
getAsync
public CompletableFuture<V> getAsync(K key)
Description copied from interface:CacheAsynchronously returns the value associated with the key in this cache.
-
putAsync
public CompletableFuture<Void> putAsync(K key, V value)
Description copied from interface:CacheAsynchronously associates the specified value with the specified key in this cache.
-
removeAsync
public CompletableFuture<V> removeAsync(K key)
Description copied from interface:CacheAsynchronously removes the mapping for a key from this cache if it is present.- Specified by:
removeAsyncin interfaceCache<K,V>- Parameters:
key- key whose mapping is to be removed from the cache- Returns:
- a CompletableFuture that will be completed with the previous value associated with key, or null if there was no mapping for key
-
clearAsync
public CompletableFuture<Void> clearAsync()
Description copied from interface:CacheAsynchronously removes all mappings from this cache.- Specified by:
clearAsyncin interfaceCache<K,V>- Returns:
- a CompletableFuture that will be completed when the operation is done
-
-