LocalCacheService
A local, in-memory service for caching mechanisms and reactions with a time-to-live (TTL) mechanism.
This service uses a TrieMap
for thread-safe, concurrent caching. Each cache entry is timestamped, and expired entries are removed based on the configured TTL. The service provides CRUD operations for mechanisms and reactions, ensuring expired entries are not returned or updated.
Type parameters
- F
-
The effect type (e.g.,
IO
,SyncIO
, etc.) used to encapsulate computations.
Value parameters
- ttl
-
The time-to-live (TTL) for cache entries. Entries older than this duration are considered expired.
Attributes
- Source
- LocalCacheService.scala
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Removes expired entries from all caches.
Removes expired entries from all caches.
This method checks the timestamp of each cache entry and removes entries that have exceeded the configured TTL. This operation is performed in-memory and is thread-safe.
Attributes
- Returns
-
An effectful computation that completes when all expired entries have been removed.
- Source
- LocalCacheService.scala
Creates a mechanism in the cache if it doesn't already exist.
Creates a mechanism in the cache if it doesn't already exist.
Value parameters
- id
-
The ID of the mechanism.
- mechanism
-
The
Mechanism
instance to create.
Attributes
- Returns
-
An effect wrapping either an error message if the mechanism exists, or the created mechanism.
- Definition Classes
- Source
- LocalCacheService.scala
Creates a reaction in the cache if it doesn't already exist.
Creates a reaction in the cache if it doesn't already exist.
Value parameters
- id
-
The ID of the reaction.
- reaction
-
The
Reaction
instance to create.
Attributes
- Returns
-
An effect wrapping either an error message if the reaction exists, or the created reaction.
- Definition Classes
- Source
- LocalCacheService.scala
Retrieves a mechanism from the cache.
Retrieves a mechanism from the cache.
Value parameters
- id
-
The ID of the mechanism.
Attributes
- Returns
-
An effect wrapping an optional
Mechanism
. - Definition Classes
- Source
- LocalCacheService.scala
Retrieves a mechanism's details from the cache.
Retrieves a mechanism's details from the cache.
Value parameters
- id
-
The ID of the mechanism.
Attributes
- Returns
-
An effect wrapping an optional
MechanismDetails
. - Definition Classes
- Source
- LocalCacheService.scala
Retrieves a reaction from the cache.
Retrieves a reaction from the cache.
Value parameters
- id
-
The ID of the reaction.
Attributes
- Returns
-
An effect wrapping an optional
Reaction
. - Definition Classes
- Source
- LocalCacheService.scala
Retrieves a reaction's details from the cache.
Retrieves a reaction's details from the cache.
Value parameters
- id
-
The ID of the reaction.
Attributes
- Returns
-
An effect wrapping an optional
ReactionDetails
. - Definition Classes
- Source
- LocalCacheService.scala
Caches a mechanism by its ID.
Caches a mechanism by its ID.
Value parameters
- id
-
The ID of the mechanism.
- mechanism
-
The
Mechanism
instance to cache.
Attributes
- Returns
-
An effect indicating completion.
- Definition Classes
- Source
- LocalCacheService.scala
Caches a mechanism's details by its ID.
Caches a mechanism's details by its ID.
Value parameters
- id
-
The ID of the mechanism.
- mechanismDetails
-
The
MechanismDetails
instance to cache.
Attributes
- Returns
-
An effect indicating completion.
- Definition Classes
- Source
- LocalCacheService.scala
Caches a reaction by its ID.
Caches a reaction by its ID.
Value parameters
- id
-
The ID of the reaction.
- reaction
-
The
Reaction
instance to cache.
Attributes
- Returns
-
An effect indicating completion.
- Definition Classes
- Source
- LocalCacheService.scala
Caches a reaction's details by its ID.
Caches a reaction's details by its ID.
Value parameters
- id
-
The ID of the reaction.
- reactionDetails
-
The
ReactionDetails
instance to cache.
Attributes
- Returns
-
An effect indicating completion.
- Definition Classes
- Source
- LocalCacheService.scala