A durable atom and agent type for Clojure that persists state to various backends like files, databases, and cloud storage.
Duratom is a Clojure library that provides durable atom and agent types, persisting their state to various storage backends like files, databases, and cloud services on every mutation. It solves the problem of losing in-memory state due to process restarts or crashes, ensuring data durability while maintaining the same API as core Clojure atoms.
Clojure developers building stateful applications that require persistent state across restarts, such as long-running servers, data processing pipelines, or systems where losing atom state is unacceptable.
Developers choose Duratom because it's a drop-in replacement for Clojure atoms with no API changes, supports multiple backends for flexibility, and offers configurable serialization and error handling, making it both robust and easy to integrate.
A durable atom type for Clojure
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Implements IAtom, IRef, and IDeref interfaces, making it interchangeable with core Clojure atoms—no code changes needed for basic integration, as shown in the usage examples.
Supports six backends including local files, PostgreSQL, SQLite, AWS S3, Redis, and file.io, allowing deployment in diverse environments from cloud to embedded systems.
Enables custom read/write functions with built-in support for Nippy encoding and EDN with metadata preservation, handling complex types like sorted maps and PersistentQueue.
Provides :error-handler for commit failures, allowing logging or retries, with safe recommit options in synchronous mode or with duragent for robustness.
Some backends like file.io require managing ephemeral keys and custom HTTP functions, adding operational overhead compared to simpler storage solutions.
Default async commits can cause temporary mismatches between in-memory state and storage, necessitating careful handling in consistency-critical apps, as noted in the async commits section.
Backends have caveats: Redis is in-memory and may lose data without persistence, file.io has rate limits and ephemeral files, and EDN serialization excludes NaN and mutable Java objects.