Expand description
NestJS @nestjs/locks analogue —
lease-based distributed locks for single-runner cron and critical sections.
§Example
ⓘ
use nestrs_locks::{LocksModule, LocksOptions, LocksService};
let dm = LocksModule::register(LocksOptions::default());
if let Some(guard) = locks.try_acquire("cron:nightly").await {
// exclusive work
guard.release().await;
}Choose default_ttl carefully: shorter than tolerable duplicate work after a crash,
longer than healthy job duration (or extend the lease). Redis store: feature cache-redis.
Umbrella feature: nestrs / locks → nestrs::locks.
Structs§
- Dynamic
Module - Runtime-composed module unit for conditional imports (feature flags, env switches, plugins).
- InMemory
Lock Store - Lock
Guard - Locks
Module - Locks
Options - Locks
Service - High-level lock service (NestJS LocksService analogue).
- Provider
Registry - Shared
InMemory Lock Store - Arc-backed in-memory store (preferred).
Traits§
- Injectable
- Application service or provider type constructed through the DI container.
- Lock
Store