Provider-Agnostic Storage for Go. Write Once, Store Anywhere.
Type-safe CRUD across databases, key-value stores, blob storage, and vector indices. Swap backends without touching business logic.
Get Startedimport "github.com/zoobz-io/grub"
// Same code, different backends
sessions := grub.NewStore[Session](redis.New(client))
sessions := grub.NewStore[Session](badger.New(db))
sessions := grub.NewStore[Session](bolt.New(db, "sessions"))
// Type-safe operations — returns *Session, not interface{}
session, _ := sessions.Get(ctx, "session:abc")
sessions.Set(ctx, "session:xyz", &Session{UserID: "123"}, time.Hour)
// Four storage modes, one pattern
users := grub.NewDatabase[User](postgres.New(db, "users"))
docs := grub.NewBucket[Document](s3.New(client, "documents"))
vecs := grub.NewIndex[Embedding](qdrant.New(client, "embeddings"))
// Consistent errors across all providers
user, err := users.Get(ctx, "usr-123")
if errors.Is(err, grub.ErrNotFound) {
// Same error whether it's Redis, PostgreSQL, or S3
}Why Grub?
Storage becomes a configuration choice, not an architectural constraint.
Four Storage Modes
Store (key-value), Database (SQL), Bucket (blobs), Index (vectors). One pattern, every backend.
Type-Safe Generics
Get returns *T, Query returns []*T. The compiler enforces types across every storage operation.
Semantic Error Consistency
ErrNotFound, ErrDuplicate, ErrConflict mean the same thing whether it's Redis, PostgreSQL, or S3.
Lifecycle Hooks
BeforeSave, AfterLoad, BeforeDelete — validation, normalization, and side-effects without scattering logic.
Modular Providers
Each provider is a separate Go module. Only import Redis if you use Redis. Clean dependency graph.
Atomic Views
Field-level access via atomization for encryption pipelines, data transformations, and framework internals.
Capabilities
CRUD operations, caching strategies, blob storage, vector search, and provider migrations — all behind one interface.
| Feature | Description | Link |
|---|---|---|
| Key-Value Storage | Get, Set, Delete, Exists with optional TTL. Redis, BadgerDB, and BoltDB providers. | Providers |
| SQL Databases | Type-safe queries, transactions, and aggregates via soy builders. PostgreSQL, MariaDB, SQLite, SQL Server. | Lifecycle |
| Blob Storage | Put, Get, Delete with typed payloads and metadata. S3, MinIO, Google Cloud Storage, Azure Blob. | Best Practices |
| Vector Search | Similarity search with typed metadata and filters. Qdrant, Pinecone, Milvus, Weaviate. | Vector Search |
| Caching Patterns | Cache-aside, read-through, and TTL strategies with consistent invalidation across providers. | Caching |
| Provider Migrations | Dual-write, shadow-read, and big-bang patterns for zero-downtime backend switches. | Migrations |
Articles
Browse the full grub documentation.