ext/web W4: Postgres, Redis/memory cache, and S3/file storage drivers
URL-scheme backends keep the same # db CRUD author API; add # cache and Co-authored-by: Cursor <cursoragent@cursor.com> # storage with offline memory:/file: gold coverage.
This commit is contained in:
1 parent
e7c9c21a49
commit
034f52b7e7
14 files changed
+2504
-17
No files matched your search
@@ -142,6 +142,8 @@ Style tables live as `##` exports in site style modules; compose resolves them b
|
||||
# db
|
||||
+ `url`="sqlite:site.db"
|
||||
|
||||
Open a database handle. URL schemes: `sqlite:path` (default), `postgres://…` / `postgresql://…` (same CRUD methods).
|
||||
|
||||
> ensure_plugin
|
||||
**> web_db_new url=`url`**
|
||||
|
||||
@@ -488,6 +490,85 @@ Hash a plaintext password for storage in admin user tables (argon2id). Store the
|
||||
|
||||
**> web_password_hash password=`password`**
|
||||
|
||||
# cache
|
||||
+ `url`="memory:"
|
||||
|
||||
Key–value cache. Use `memory:` for in-process (tests / single process) or `redis://host:6379/0` for Redis.
|
||||
|
||||
> ensure_plugin
|
||||
**> web_cache_new url=`url`**
|
||||
|
||||
## get
|
||||
+ `key`
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_cache_get url=`url` key=`key`**
|
||||
|
||||
## set
|
||||
+ `key`
|
||||
+ `value`
|
||||
+ `ttl`=None
|
||||
|
||||
Optional `ttl` is seconds until expiry.
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_cache_set url=`url` key=`key` value=`value` ttl=`ttl`**
|
||||
|
||||
## del
|
||||
+ `key`
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_cache_del url=`url` key=`key`**
|
||||
|
||||
## exists
|
||||
+ `key`
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_cache_exists url=`url` key=`key`**
|
||||
|
||||
## ttl
|
||||
+ `key`
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_cache_ttl url=`url` key=`key`**
|
||||
|
||||
# storage
|
||||
+ `url`="file:data/blobs"
|
||||
|
||||
Object storage. `file:dir` stores blobs on disk (offline / gold). `s3://bucket?endpoint=http://127.0.0.1:9000&access_key=…&secret_key=…` talks to MinIO / S3.
|
||||
|
||||
> ensure_plugin
|
||||
**> web_storage_new url=`url`**
|
||||
|
||||
## put
|
||||
+ `key`
|
||||
+ `body`=None
|
||||
+ `path`=None
|
||||
+ `content_type`="application/octet-stream"
|
||||
|
||||
Provide either `body` (text) or `path` (local file to upload).
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_storage_put url=`url` key=`key` body=`body` path=`path` content_type=`content_type`**
|
||||
|
||||
## get
|
||||
+ `key`
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_storage_get url=`url` key=`key`**
|
||||
|
||||
## delete
|
||||
+ `key`
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_storage_delete url=`url` key=`key`**
|
||||
|
||||
## list
|
||||
+ `prefix`=""
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_storage_list url=`url` prefix=`prefix`**
|
||||
|
||||
# ws
|
||||
+ `timeout_sec`=30
|
||||
|
||||
|
||||
@@ -129,6 +129,8 @@ SEO / OpenGraph 元数据表(`|键|值|`)。如 `title`、`description`、`c
|
||||
# 数据库
|
||||
+ `地址`="sqlite:site.db"
|
||||
|
||||
打开数据库句柄。URL 方案:`sqlite:路径`(默认)、`postgres://…` / `postgresql://…`(CRUD 方法相同)。
|
||||
|
||||
> 确保插件
|
||||
**> web_db_new url=`地址`**
|
||||
|
||||
@@ -470,6 +472,85 @@ SEO / OpenGraph 元数据表(`|键|值|`)。如 `title`、`description`、`c
|
||||
|
||||
**> web_password_hash password=`密码`**
|
||||
|
||||
# 缓存
|
||||
+ `地址`="memory:"
|
||||
|
||||
键值缓存。`memory:` 为进程内(测试 / 单进程);`redis://主机:6379/0` 连 Redis。
|
||||
|
||||
> 确保插件
|
||||
**> web_cache_new url=`地址`**
|
||||
|
||||
## 获取
|
||||
+ `键`
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_cache_get url=`url` key=`键`**
|
||||
|
||||
## 设置
|
||||
+ `键`
|
||||
+ `值`
|
||||
+ `过期`=None
|
||||
|
||||
`过期` 为秒;省略则不过期。
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_cache_set url=`url` key=`键` value=`值` ttl=`过期`**
|
||||
|
||||
## 删除
|
||||
+ `键`
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_cache_del url=`url` key=`键`**
|
||||
|
||||
## 存在
|
||||
+ `键`
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_cache_exists url=`url` key=`键`**
|
||||
|
||||
## 剩余时间
|
||||
+ `键`
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_cache_ttl url=`url` key=`键`**
|
||||
|
||||
# 存储
|
||||
+ `地址`="file:data/blobs"
|
||||
|
||||
对象存储。`file:目录` 落本地盘(离线 / 金样);`s3://桶?endpoint=http://127.0.0.1:9000&access_key=…&secret_key=…` 连 MinIO / S3。
|
||||
|
||||
> 确保插件
|
||||
**> web_storage_new url=`地址`**
|
||||
|
||||
## 上传
|
||||
+ `键`
|
||||
+ `正文`=None
|
||||
+ `路径`=None
|
||||
+ `类型`="application/octet-stream"
|
||||
|
||||
`正文`(文本)与 `路径`(本地文件)二选一。
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_storage_put url=`url` key=`键` body=`正文` path=`路径` content_type=`类型`**
|
||||
|
||||
## 下载
|
||||
+ `键`
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_storage_get url=`url` key=`键`**
|
||||
|
||||
## 删除对象
|
||||
+ `键`
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_storage_delete url=`url` key=`键`**
|
||||
|
||||
## 列出
|
||||
+ `前缀`=""
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_storage_list url=`url` prefix=`前缀`**
|
||||
|
||||
# 实时
|
||||
+ `超时秒`=30
|
||||
|
||||
|
||||
Reference in new issue
Block a user