MCPcopy Index your code
hub / github.com/nalgeon/redka

github.com/nalgeon/redka @v1.0.1 sqlite

repository ↗ · DeepWiki ↗ · release v1.0.1 ↗
1,241 symbols 7,899 edges 268 files 554 documented · 45%
README

Redka

Redka aims to reimplement the core parts of Redis with SQL, while remaining compatible with Redis API.

Highlights:

  • Data doesn't have to fit in RAM.
  • Supports ACID transactions.
  • SQL views for easier analysis and reporting.
  • Uses SQLite or PostgreSQL as a backend.
  • Runs in-process (Go API) or as a standalone server.
  • Implements Redis commands and wire protocol (RESP).

Redka is functionally ready for 1.0. Feel free to try it in non-critical production scenarios and provide feedback in the issues.

Use cases

Here are some situations where Redka might be helpful:

Embedded cache for Go applications. If your Go app already uses SQLite or just needs a built-in key-value store, Redka is a natural fit. It gives you Redis-like features without the hassle of running a separate server. You're not limited to just get/set with expiration, of course — more advanced structures like lists, maps, and sets are also available.

Lightweight testing environment. Your app uses Redis in production, but setting up a Redis server for local development or integration tests can be a hassle. Redka with an in-memory database offers a fast alternative to test containers, providing full isolation for each test run.

Postgres-first data structures. If you prefer to use PostgreSQL for everything but need Redis-like data structures, Redka can use your existing database as the backend. This way, you can manage both relational data and specialized data structures with the same tools and transactional guarantees.

Commands

Redka supports five core Redis data types:

  • Strings are the most basic Redis type, representing a sequence of bytes.
  • Lists are sequences of strings sorted by insertion order.
  • Sets are unordered collections of unique strings.
  • Hashes are field-value (hash)maps.
  • Sorted sets (zsets) are collections of unique strings ordered by each string's associated score.

Redka also provides commands for key management, server/connection management, and transactions.

Installation and usage

Redka comes in two flavors:

You can also run an in-process Redka server as a lightweight alternative to Redis test containers, or as a small-scale production instance.

Storage

Redka can use either SQLite or PostgreSQL as its backend. It stores data in a relational database with a simple schema and provides views for better introspection.

Performance

Redka is not about raw performance. You can't beat a specialized data store like Redis with a general-purpose relational backend like SQLite. However, Redka can still handle tens of thousands of operations per second, which should be more than enough for many apps.

See the benchmarks for more details.

Contributing

Contributions are welcome. For anything other than bugfixes, please first open an issue to discuss what you want to change.

Make sure to add or update tests as needed.

Acknowledgements

Redka would not be possible without these great projects and their creators:

Logo font by Ek Type.

Support

Redka is mostly a one-man project, not backed by a VC fund or anything.

If you find Redka useful, please star it on GitHub and spread the word among your peers. It really helps to move the project forward.

If you use Redka for commercial purposes, consider purchasing support.

Subscribe to stay on top of new features.

Extension points exported contracts — how you extend this code

RowScanner (Interface)
rowScanner is an interface to scan rows. [12 implementers]
internal/sqlx/sql.go
Writer (Interface)
Writer is an interface to write responses to the client. [2 implementers]
redsrv/internal/redis/redis.go
Tx (Interface)
Tx is a database transaction (or a transaction-like object). This is an abstraction over sql.Tx and sql.DB.
internal/sqlx/sql.go
RHash (Interface)
RHash is a hash repository. [2 implementers]
redsrv/internal/redis/redka.go
RKey (Interface)
RKey is a key repository. [2 implementers]
redsrv/internal/redis/redka.go
RList (Interface)
RList is a list repository. [2 implementers]
redsrv/internal/redis/redka.go
RSet (Interface)
RSet is a set repository. [2 implementers]
redsrv/internal/redis/redka.go

Core symbols most depended-on inside this repo

Run
called by 1394
redsrv/internal/redis/redis.go
Err
called by 741
internal/rset/scanner.go
Set
called by 619
redsrv/internal/redis/redka.go
Add
called by 560
redsrv/internal/redis/redka.go
Get
called by 465
redsrv/internal/redis/redka.go
Out
called by 421
redsrv/internal/redis/conn.go
MustParse
called by 418
redsrv/internal/redis/redis.go
NewFakeConn
called by 418
redsrv/internal/redis/conn.go

Shape

Method 552
Function 526
Struct 147
Interface 10
TypeAlias 5
FuncType 1

Languages

Go100%

Modules by API surface

redsrv/internal/redis/redka.go102 symbols
redka.go30 symbols
internal/rzset/tx.go28 symbols
redsrv/internal/redis/redis.go27 symbols
internal/rset/tx.go25 symbols
redsrv/internal/redis/conn.go24 symbols
redsrv/handlers_test.go24 symbols
internal/rhash/tx.go24 symbols
internal/rlist/tx.go23 symbols
internal/rzset/db_test.go22 symbols
internal/rkey/tx.go21 symbols
redka_test.go20 symbols

Dependencies from manifests, versioned

github.com/cespare/xxhash/v2v2.3.0 · 1×
github.com/dgryski/go-rendezvousv0.0.0-2020082301473 · 1×
github.com/lib/pqv1.11.1 · 1×
github.com/mattn/go-isattyv0.0.16 · 1×
github.com/mattn/go-sqlite3v1.14.33 · 1×
github.com/nalgeon/bev0.3.0 · 1×
github.com/nalgeon/redkav0.0.0-0001010100000 · 1×
github.com/ncruces/go-sqlite3v0.16.2 · 1×
github.com/ncruces/go-strftimev0.1.9 · 1×

Datastores touched

redkaDatabase · 1 repos
mydbDatabase · 1 repos

For agents

$ claude mcp add redka \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact