LocalCacheService

core.services.cache.LocalCacheService
class LocalCacheService[F[_]](implicit evidence$1: Sync[F], ttl: FiniteDuration) extends CacheServiceTrait[F]

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
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def cleanExpiredEntries: F[Unit]

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
override def createMechanism(id: MechanismId, mechanism: Mechanism): F[Either[String, Mechanism]]

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
override def createReaction(id: ReactionId, reaction: Reaction): F[Either[String, Reaction]]

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
override def getMechanism(id: MechanismId): F[Option[Mechanism]]

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
override def getMechanismDetails(id: MechanismId): F[Option[MechanismDetails]]

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
override def getReaction(id: ReactionId): F[Option[Reaction]]

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
override def getReactionDetails(id: ReactionId): F[Option[ReactionDetails]]

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
override def putMechanism(id: MechanismId, mechanism: Mechanism): F[Unit]

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
override def putMechanismDetails(id: MechanismId, mechanismDetails: MechanismDetails): F[Unit]

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
override def putReaction(id: ReactionId, reaction: Reaction): F[Unit]

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
override def putReactionDetails(id: ReactionId, reactionDetails: ReactionDetails): F[Unit]

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