rs-zero 0.2.21

Rust-first microservice framework inspired by go-zero engineering practices
Documentation
# model-cache

This fixture drives the model/cache generator and documents runtime cache usage.

```bash
rzcli model gen -s examples/model-cache/schema.sql -d target/generated --with-sqlx --with-redis-cache
```

The generated crate contains:

- `src/entity/<table>.rs` with serde DTO entities and optional `sqlx::FromRow` derives.
- `src/repository/<table>.rs` with repository traits, SQLx repositories, and optional cache-aside repositories.
- `src/repository_ext.rs` for hand-written repository extensions; preserved by `model gen --force`.
- `src/cache/<table>.rs` with primary/unique cache key helpers plus `src/cache/mod.rs` Redis/L1/L2 cache aliases when enabled.

The generator does not own credentials, migrations, transaction boundaries, or Redis topology. Application code wires the generated repository with runtime stores.

```rust
use rs_zero::cache::{CacheAside, CacheAsideConfig, LruCacheStore, TwoLevelCacheStore};
use rs_zero::cache::redis::{RedisCacheConfig, RedisCacheStore};
use user_model::repository::{CachedUserRepository, SqlxUserRepository};

let sql_repo = SqlxUserRepository::new();
let l1 = LruCacheStore::new(10_000)?;
let l2 = RedisCacheStore::new(RedisCacheConfig::default())?;
let cache = CacheAside::new(TwoLevelCacheStore::new(l1, l2), CacheAsideConfig::default());
let repo = CachedUserRepository::new(sql_repo, pool.clone(), cache, "user-service");
```

Use the SQLx repository directly when a transaction owns the executor:

```rust
let users = SqlxUserRepository::new();
let mut tx = pool.begin().await?;
users.save(&mut *tx, &user).await?;
tx.commit().await?;
```

See [Model/cache 手册](../../docs/manual/model-cache.md) and [Cache 手册](../../docs/manual/cache.md).