Class PostgresCacheAdapter
java.lang.Object
org.fireflyframework.cache.adapter.postgres.PostgresCacheAdapter
- All Implemented Interfaces:
org.fireflyframework.cache.core.CacheAdapter
public class PostgresCacheAdapter
extends Object
implements org.fireflyframework.cache.core.CacheAdapter
PostgreSQL-backed reactive cache adapter implemented over R2DBC.
Cache entries are stored in a single relational table keyed by
(cache_name, cache_key). Values are serialized with a
CacheSerializer into a JSON String, encoded as UTF-8 bytes and
persisted in a BYTEA column. Expiry is enforced both lazily on read
(rows whose expires_at is in the past are treated as absent) and at
write time (expires_at = NOW() + ttl).
All operations run reactively against a Spring-managed
ConnectionFactory; connections are acquired and released per operation
via Mono.usingWhen(Publisher, java.util.function.Function, java.util.function.Function).
-
Constructor Summary
ConstructorsConstructorDescriptionPostgresCacheAdapter(String cacheName, io.r2dbc.spi.ConnectionFactory connectionFactory, PostgresCacheConfig config, org.fireflyframework.cache.serialization.CacheSerializer serializer) -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void> clear()voidclose()<K> reactor.core.publisher.Mono<Boolean> evict(K key) reactor.core.publisher.Mono<Long> evictByPrefix(String keyPrefixToMatch) <K> reactor.core.publisher.Mono<Boolean> exists(K key) <K,V> reactor.core.publisher.Mono <Optional<V>> get(K key) <K,V> reactor.core.publisher.Mono <Optional<V>> org.fireflyframework.cache.core.CacheTypereactor.core.publisher.Mono<org.fireflyframework.cache.core.CacheHealth> reactor.core.publisher.Mono<org.fireflyframework.cache.core.CacheStats> getStats()boolean<K> reactor.core.publisher.Mono<Set<K>> keys()<K,V> reactor.core.publisher.Mono <Void> put(K key, V value) <K,V> reactor.core.publisher.Mono <Void> <K,V> reactor.core.publisher.Mono <Boolean> putIfAbsent(K key, V value) <K,V> reactor.core.publisher.Mono <Boolean> putIfAbsent(K key, V value, Duration ttl) reactor.core.publisher.Mono<Long> size()
-
Constructor Details
-
PostgresCacheAdapter
public PostgresCacheAdapter(String cacheName, io.r2dbc.spi.ConnectionFactory connectionFactory, PostgresCacheConfig config, org.fireflyframework.cache.serialization.CacheSerializer serializer)
-
-
Method Details
-
get
- Specified by:
getin interfaceorg.fireflyframework.cache.core.CacheAdapter
-
get
-
put
- Specified by:
putin interfaceorg.fireflyframework.cache.core.CacheAdapter
-
put
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceorg.fireflyframework.cache.core.CacheAdapter
-
putIfAbsent
-
evict
- Specified by:
evictin interfaceorg.fireflyframework.cache.core.CacheAdapter
-
clear
- Specified by:
clearin interfaceorg.fireflyframework.cache.core.CacheAdapter
-
evictByPrefix
-
exists
- Specified by:
existsin interfaceorg.fireflyframework.cache.core.CacheAdapter
-
keys
- Specified by:
keysin interfaceorg.fireflyframework.cache.core.CacheAdapter
-
size
- Specified by:
sizein interfaceorg.fireflyframework.cache.core.CacheAdapter
-
getStats
public reactor.core.publisher.Mono<org.fireflyframework.cache.core.CacheStats> getStats()- Specified by:
getStatsin interfaceorg.fireflyframework.cache.core.CacheAdapter
-
getCacheType
public org.fireflyframework.cache.core.CacheType getCacheType()- Specified by:
getCacheTypein interfaceorg.fireflyframework.cache.core.CacheAdapter
-
getCacheName
- Specified by:
getCacheNamein interfaceorg.fireflyframework.cache.core.CacheAdapter
-
isAvailable
public boolean isAvailable()- Specified by:
isAvailablein interfaceorg.fireflyframework.cache.core.CacheAdapter
-
getHealth
public reactor.core.publisher.Mono<org.fireflyframework.cache.core.CacheHealth> getHealth()- Specified by:
getHealthin interfaceorg.fireflyframework.cache.core.CacheAdapter
-
close
public void close()- Specified by:
closein interfaceorg.fireflyframework.cache.core.CacheAdapter
-