@gravito/stasis 1.0.0-beta.2 → 1.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.zh-TW.md +38 -0
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +7 -7
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +7 -7
- package/package.json +5 -5
package/README.zh-TW.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @gravito/stasis
|
|
2
|
+
|
|
3
|
+
> Gravito 的快取 Orbit,提供類 Laravel 的 Cache API。
|
|
4
|
+
|
|
5
|
+
## 安裝
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @gravito/stasis
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 快速開始
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { PlanetCore } from 'gravito-core'
|
|
15
|
+
import orbitCache from '@gravito/stasis'
|
|
16
|
+
|
|
17
|
+
const core = new PlanetCore()
|
|
18
|
+
|
|
19
|
+
const cache = orbitCache(core, {
|
|
20
|
+
exposeAs: 'cache',
|
|
21
|
+
default: 'memory',
|
|
22
|
+
prefix: 'app_cache:',
|
|
23
|
+
defaultTtl: 60,
|
|
24
|
+
stores: {
|
|
25
|
+
memory: { driver: 'memory', maxItems: 10_000 },
|
|
26
|
+
file: { driver: 'file', directory: './tmp/cache' },
|
|
27
|
+
null: { driver: 'null' },
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
core.app.get('/heavy-data', async (c) => {
|
|
32
|
+
const data = await cache.remember('heavy_key', 300, async () => {
|
|
33
|
+
return { result: 42 }
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
return c.json(data)
|
|
37
|
+
})
|
|
38
|
+
```
|
package/dist/index.cjs
CHANGED
|
@@ -11087,6 +11087,7 @@ class OrbitCache {
|
|
|
11087
11087
|
core.adapter.use("*", async (c, next) => {
|
|
11088
11088
|
c.set(exposeAs, manager2);
|
|
11089
11089
|
await next();
|
|
11090
|
+
return;
|
|
11090
11091
|
});
|
|
11091
11092
|
core.services.set(exposeAs, manager2);
|
|
11092
11093
|
core.hooks.doAction("cache:init", manager2);
|
|
@@ -11104,4 +11105,4 @@ function orbitCache(core, options = {}) {
|
|
|
11104
11105
|
return orbit.getCache();
|
|
11105
11106
|
}
|
|
11106
11107
|
|
|
11107
|
-
//# debugId=
|
|
11108
|
+
//# debugId=62D23CFD465AE09A64756E2164756E21
|