Skip to content

feat: add redis, mongodb and sqlx session stores#68

Closed
chrislearn wants to merge 4 commits intohttp-rs:mainfrom
salvo-rs:feat/pluggable-stores
Closed

feat: add redis, mongodb and sqlx session stores#68
chrislearn wants to merge 4 commits intohttp-rs:mainfrom
salvo-rs:feat/pluggable-stores

Conversation

@chrislearn
Copy link
Copy Markdown
Contributor

Summary

  • Three new pluggable session stores behind cargo features: redis, mongodb, and sqlx (with sub-features sqlx-postgres / sqlx-sqlite / sqlx-mysql).
  • All SQLx stores use sqlx::Pool for connection pooling; RedisStore uses ConnectionManager; MongoDbStore relies on the official driver's built-in pool.
  • Bilingual (en/zh) usage docs under docs/ and ignored integration tests for every backend.

Stores

Store Feature Notes
RedisStore redis TTL via SET ... EX, configurable key prefix
MongoDbStore mongodb initialize() creates a TTL index on expires_at
SqlxPostgresStore sqlx-postgres migrate() / cleanup() helpers
SqlxSqliteStore sqlx-sqlite same API
SqlxMySqlStore sqlx-mysql same API

SQLx stores share a portable schema (expires stored as BIGINT unix seconds) so no extra sqlx type-conversion features are required.

Test plan

  • cargo check --features redis
  • cargo check --features mongodb
  • cargo check --features sqlx-postgres,sqlx-sqlite,sqlx-mysql
  • cargo test --features redis,mongodb,sqlx-postgres,sqlx-sqlite,sqlx-mysql --no-run
  • Run ignored integration tests against live services (see docs/en/stores.md for commands)

🤖 Generated with Claude Code

chrislearn and others added 4 commits January 2, 2026 19:01
- Use tokio for test and doc
- Use postcard for bincode is deprecated.
Adds three new pluggable session stores behind cargo features:

- `redis` → `RedisStore` (uses ConnectionManager for connection reuse)
- `mongodb` → `MongoDbStore` (TTL index via `initialize()`)
- `sqlx` + `sqlx-postgres` / `sqlx-sqlite` / `sqlx-mysql` →
  `SqlxPostgresStore` / `SqlxSqliteStore` / `SqlxMySqlStore`,
  all using `sqlx::Pool` for connection pooling

Includes ignored integration tests for every backend and bilingual
(en/zh) usage docs under `docs/`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@chrislearn
Copy link
Copy Markdown
Contributor Author

Opened against the wrong repo by mistake — re-creating against salvo-rs/saysion.

@chrislearn chrislearn closed this Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant