stash
5.2.0, released 3 years ago by ivoleitao.dev
Key-value store abstraction with caching semantics and pluggable backends.
What it does
Provides a key-value storage abstraction with plain vault semantics and advanced cache-driven semantics. It supports multiple eviction and expiration policies, binary serialization, events, and a pluggable backend architecture.
AI-written summary of version 5.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need advanced caching semantics like expiration and eviction policies.
- You want a unified key-value abstraction that can swap storage backends easily.
- You need tiered caching with an in-memory primary cache and secondary persistent storage.
Skip it when
- You need a full relational database with complex queries and joins.
- You only want simple preferences without any caching features and prefer a lighter direct dependency.
Strengths
- Rich caching features including multiple expiry and eviction policies (LRU, LFU, FIFO, etc.).
- Pluggable backend architecture supporting memory, file, SQLite, Hive, and more.
- Out-of-the-box binary serialization using msgpack.
Weaknesses
- Requires adding both the core API package and a separate storage provider package.
- API surface can be complex due to many configuration options and policies.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 5
Add stash and your chosen storage implementation (e.g., stash_memory) to pubspec.yaml.
import 'package:stash/stash_api.dart';
import 'package:stash/stash_memory.dart';
void main() async {
final store = await newMemoryCacheStore();
final cache = await store.cache<String>(maxEntries: 10);
await cache.put('key1', 'value1');
final value = await cache.get('key1');
}Alternatives
Packages that do the same job and could replace stash.
- hive_ce
If you want a lightweight standalone NoSQL database without the abstraction layer overhead of Stash.
96Compare - shared_preferences
If you only need simple key-value storage for basic app settings.
97Compare
Works with
Packages commonly used together with stash: ones it builds on, ones built on it, and its own family.
- uuidstash depends on itGenerates and parses RFC‑4122/9562 UUIDs (v1‑v8) for Dart.
- clockstash depends on itA fakeable wrapper for dart:core clock APIs.
- asyncstash depends on itUtility classes and helpers that extend Dart's async library.
- equatablestash depends on itProvides value‑based equality for Dart objects without manual == and hashCode.
- stash_memoryBuilt on stashMemory storage extension for the stash API to store vaults and caches in-memory.
- stash_hiveBuilt on stashHive storage extension for the stash caching API