Skip to content

v0.6.0

Latest
Compare
Choose a tag to compare
@github-actions github-actions released this 13 Jul 19:50
· 1 commit to main since this release

Redka aims to reimplement the core parts of Redis with SQL, while remaining compatible with the Redis API. This release adds support for PostgreSQL! Now, Redka can use either SQLite or Postgres as a backend.

readme

Postgres backend

Here's an example in Go:

// Prepate connection settings.
connStr := "postgres://user:password@localhost:5432/mydb?sslmode=disable"
opts := &redka.Options{DriverName: "postgres"}

// Connect to the database.
db, _ := redka.Open(connStr, opts)
defer db.Close()

// Set some values.
db.Str().Set("name", "alice")
db.Str().Set("age", 25)

// Read them back.
name, _ := db.Str().Get("name")
fmt.Printf("name = %v\n", name)

age, _ := db.Str().Get("age")
fmt.Printf("age = %v\n", age)
name = alice
age = 25

You can also run Redka as a standalone Redis-compatible server backed by Postgres, to use with Python, JavaScript, C# or any other language:

export REDKA_DB_URL="postgres://redka:redka@localhost:5432/redka?sslmode=disable"
./redka -h localhost -p 6379

The Postgres backend supports all the data structures that Redka offers: strings, lists, sets, hashes and sorted sets (zsets).

Other changes

The new redsrv package provides a convenient API for creating and starting a Redka server. This is useful if you want to run the Redka server within your own Go application, either for testing or as a lightweight alternative to real Redis. See the server example for details.

Until Redka reaches 1.0, I may introduce breaking changes with each release. Sorry about that.

⚠️ Renamed the SetExpires method on rstring.DB and rstring.Tx to SetExpire.

⚠️ Dropped support for github.com/tursodatabase/go-libsql driver. I recommend using github.com/mattn/go-sqlite3 (CGO) or github.com/ncruces/go-sqlite3 (pure Go) instead. modernc.org/sqlite is also supported.

⚠️ Removed the undocumented redka-cli tool. You can use redis-cli or valkey-cli instead.