Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .agents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Each skill teaches domain-specific workflows for Fusion (Rust core + Python / No
| `fusion-http-routes` | Routes, `http_get` / `[HttpGet]`, `[module]`, `[action]`, Swagger |
| `fusion-release` | Version bumps, manifests, publish prep |
| `fusion-testing` | Running checks; investigating failed tests |
| `fusion-cache` | Application cache (moka default; Redis later) |

## Always-on rules

Expand Down
1 change: 1 addition & 0 deletions .agents/skills/fusion-bindings-parity/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ New public surface → show usage in **Python + Node + C#**. Prefer the same bas
| Custom HTTP | `@http_get("path/[action]")` | `httpGet('path/[action]')(proto.method)` | `[HttpGet("path/[action]")]` |
| Middleware | `middleware.py` factories | factories in `index.js` | `Middleware.cs` |
| Static files | `static_files()` | `staticFiles()` | `Middleware.StaticFiles()` |
| Cache | `fusion_framework.cache` (moka) | `cache` export | `Cache` class |
| Permissions | `permissions=` / `require_permissions` | `permissions` / `requirePermissions` | `PermissionTypes` / `RequirePermissions` |
| OpenAPI / Swagger | `app.py` + `api_types.rs` | `buildOpenApi` in `index.js` | `Swagger.cs` |
| Version navbar | per-version OpenAPI routes | same | same |
Expand Down
95 changes: 95 additions & 0 deletions .agents/skills/fusion-cache/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
name: fusion-cache
description: >-
Documents Fusion application cache (default moka driver, Redis reserved),
settings under fusion.<env>.json, sync/async APIs, TTL rules, and clear
across Python, Node, and C#. Use when adding cache usage or changing drivers.
---

# Fusion cache

Process-wide cache shared by Python / Node / C# via `fusion-core`.

## Default driver

**moka** (in-process Rust cache). Settings alias `mako` is accepted and maps to `moka`.

Redis (`cache.driver = "redis"`) is reserved in settings but **not implemented yet**.

## Settings (`fusion.dev.json` / stage / prod)

```json
"cache": {
"driver": "moka",
"max_capacity": 10000,
"default_ttl": null,
"connection_string": null,
"host": "127.0.0.1",
"port": 6379,
"username": null,
"password": null,
"db": 0
}
```

| Key | Purpose |
|-----|---------|
| `driver` | `moka` (default) or future `redis` |
| `max_capacity` | moka max entries |
| `default_ttl` | seconds, or **`null` = no expiry** unless code passes `ttl=` |
| `connection_string` / `host` / `port` / `username` / `password` / `db` | Redis connection (future) |

### TTL rules

1. `cache.set("k", value, ttl=200)` → expires in 200 seconds (always wins).
2. `cache.set("k", value)` with `default_ttl: null` → **forever** (until delete/clear).
3. `cache.set("k", value)` with `default_ttl: 3600` → expires in 3600 seconds.

Same rules apply to `get_or_set` / `delete_or_set` / `exists_or_set` and their async variants.

## Sync API

| Python | Node | C# |
|--------|------|-----|
| `cache.set(..., ttl=?)` | `cache.set(..., ttl?)` | `Cache.Set(..., ttlSeconds?)` |
| `cache.get` | `cache.get` | `Cache.Get` |
| `cache.delete` | `cache.delete` | `Cache.Delete` |
| `cache.exists` | `cache.exists` | `Cache.Exists` |
| `cache.get_or_set` | `cache.getOrSet` | `Cache.GetOrSet` |
| `cache.delete_or_set` | `cache.deleteOrSet` | `Cache.DeleteOrSet` |
| `cache.exists_or_set` | `cache.existsOrSet` | `Cache.ExistsOrSet` |
| `cache.clear` | `cache.clear` | `Cache.Clear` |

## Async API

| Python | Node | C# |
|--------|------|-----|
| `await cache.aset` | `await cache.aset` | `await Cache.SetAsync` |
| `await cache.aget` | `await cache.aget` | `await Cache.GetAsync` |
| `await cache.adelete` | `await cache.adelete` | `await Cache.DeleteAsync` |
| `await cache.aexists` | `await cache.aexists` | `await Cache.ExistsAsync` |
| `await cache.aget_or_set` | `await cache.agetOrSet` | `await Cache.GetOrSetAsync` |
| `await cache.adelete_or_set` | `await cache.adeleteOrSet` | `await Cache.DeleteOrSetAsync` |
| `await cache.aexists_or_set` | `await cache.aexistsOrSet` | `await Cache.ExistsOrSetAsync` |
| `await cache.aclear` | `await cache.aclear` | `await Cache.ClearAsync` |

Semantics:

- **get_or_set** — return cached value, else store default (value or callable) and return it
- **aget_or_set** — same; factory may be **async**
- **delete_or_set** — delete then set; return stored value
- **exists_or_set** — if key exists return `true`; else set and return `false`
- **clear** — drop all keys (keeps the cache instance); **reset** (tests) drops the global instance

Values must be JSON-compatible.

## Examples

`examples/cache.py` / `.mjs` / `.cs`

## Implementation

- Core: `crates/fusion-core/src/cache.rs` (moka)
- Python: `fusion_framework.cache`
- Node: `cache` export from `fusion-framework`
- C#: `FusionFramework.Cache` via FFI
1 change: 1 addition & 0 deletions .agents/skills/fusion-cli/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ C# (`asp-core`): `main.cs`, `*.csproj` (`net10.0`), `[Route]` / `[HttpGet]`.
- `FusionBaseApi` at `api/[module]` with `version="v1"` → `/v1/api/product/…`.
- Convention verbs (`get` / `post` / …) plus one custom slot (`http_get` / `httpGet` / `[HttpGet]` with `[action]`).
- Opt-in middleware list in `main` (e.g. `request_id`, `cors`, `cache_headers`, `security_headers`, `framework_headers`). Framework does **not** auto-enable middleware; the scaffold opts in.
- Application cache defaults to **moka** (`cache` block in env JSON); see `fusion-cache` skill.

### Default ports

Expand Down
143 changes: 141 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading