update docs

This commit is contained in:
2026-04-03 11:37:12 +02:00
parent d88b0631a6
commit 692fe51728
5 changed files with 87 additions and 47 deletions
+19
View File
@@ -40,6 +40,25 @@ Protocol</a>. You can create all types,
stringify the built types into strings using <a href="#str"><code>str</code></a>, and decode from
the string protocol using <a href="#from-string"><code>from-string</code></a>. Arrays are fully
supported, including nested arrays.</p>
<pre><code>; decoding
(RESP.from-string &quot;+OK\r\n&quot;) ; =&gt; (Success (Str @&quot;OK&quot;))
(RESP.from-string &quot;:42\r\n&quot;) ; =&gt; (Success (Integer 42))
(RESP.from-string &quot;$-1\r\n&quot;) ; =&gt; (Success (Null))
; encoding
(str &amp;(RESP.Str @&quot;hi&quot;)) ; =&gt; &quot;$2\r\nhi\r\n&quot;
(str &amp;(RESP.Integer 42)) ; =&gt; &quot;:42\r\n&quot;
; pattern matching on responses
(match (Redis.get &amp;r @&quot;key&quot;)
(Result.Success resp)
(match resp
(RESP.Str s) (println* &quot;got: &quot; &amp;s)
(RESP.Null) (println* &quot;not found&quot;)
(RESP.Arr items) (println* &quot;array of &quot; &amp;(Int.str (Array.length &amp;items)))
_ (println* &quot;other&quot;))
(Result.Error e) (println* &quot;error: &quot; &amp;e))
</code></pre>
<p>If you want your types to be supported when encoding, youll have to implement
the interface <code>to-redis</code>, the signature of which is <code>(Fn [a] RESP))</code>.</p>
+10 -2
View File
@@ -38,8 +38,16 @@
<p>is a wrapper around Redis connections. It supports opening a
connection using <a href="#open"><code>open</code></a> or <a href="#open-on"><code>open-on</code></a>, reading from and
sending to the connection (using <a href="#read"><code>read</code></a> and <a href="#send"><code>send</code></a>,
respectively), and contains thin wrappers around all Redis commands (everything
else).</p>
respectively), and contains thin wrappers around all Redis commands through 7.2.</p>
<pre><code>(match (Redis.open &quot;127.0.0.1&quot;)
(Result.Success r)
(do
(println* &amp;(Redis.set &amp;r @&quot;key&quot; @&quot;val&quot;))
(println* &amp;(Redis.get &amp;r @&quot;key&quot;))
(println* &amp;(Redis.lrange &amp;r @&quot;list&quot; @&quot;0&quot; @&quot;-1&quot;))
(Redis.close r))
(Result.Error err) (IO.errorln &amp;err))
</code></pre>
</div>
<div class="binder">
-41
View File
@@ -1,41 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="../style.css">
</head>
<body>
<div class="content">
<a href="https://git.veitheller.de/carpentry/redis">
<div class="logo">
<img src="" alt="Logo">
<div class="index">
<ul>
<li>
<a href="RESP.html">
RESP
</a>
</li>
<li>
<a href="Redis.html">
Redis
</a>
</li>
</ul>
</div>
</div>
<div>
<h1>
redis
</h1>
<p>is a Redis client library for Carp.</p>
<pre><code>(load &quot;https://git.veitheller.de/carpentry/redis.git@master&quot;)
</code></pre>
</div>
</a>
</div>
</body>
</html>
+25 -2
View File
@@ -5,10 +5,33 @@
(Project.config "docs-logo" "")
(Project.config "docs-url" "https://git.veitheller.de/carpentry/redis")
(Project.config "docs-styling" "../style.css")
(Project.config "docs-prelude" "is a Redis client library for Carp.
(Project.config "docs-prelude" "is a Redis client library for Carp, supporting Redis 7.x.
## Installation
```
(load \"https://git.veitheller.de/carpentry/redis.git@master\")
(load \"https://git.veitheller.de/carpentry/redis.git@0.1.0\")
```
## Example
```
(defn main []
(match (Redis.open \"127.0.0.1\")
(Result.Success r)
(do
(println* &(Redis.set &r @\"key\" @\"value\"))
(println* &(Redis.get &r @\"key\"))
(println* &(Redis.lrange &r @\"mylist\" @\"0\" @\"-1\"))
(match (Redis.get &r @\"key\")
(Result.Success resp)
(match resp
(RESP.Str s) (println* \"got: \" &s)
(RESP.Null) (println* \"not found\")
_ (println* \"unexpected type\"))
(Result.Error e) (println* \"error: \" &e))
(Redis.close r))
(Result.Error err) (IO.errorln &err)))
```
")
+33 -2
View File
@@ -503,13 +503,44 @@ It takes the same arguments as the [Redis command](https://redis.io/commands/"
(doc Redis "is a wrapper around Redis connections. It supports opening a
connection using [`open`](#open) or [`open-on`](#open-on), reading from and
sending to the connection (using [`read`](#read) and [`send`](#send),
respectively), and contains thin wrappers around all Redis commands (everything
else).")
respectively), and contains thin wrappers around all Redis commands through 7.2.
```
(match (Redis.open \"127.0.0.1\")
(Result.Success r)
(do
(println* &(Redis.set &r @\"key\" @\"val\"))
(println* &(Redis.get &r @\"key\"))
(println* &(Redis.lrange &r @\"list\" @\"0\" @\"-1\"))
(Redis.close r))
(Result.Error err) (IO.errorln &err))
```")
(doc RESP "is a wrapper around the [Redis Serialization
Protocol](https://redis.io/topics/protocol). You can create all types,
stringify the built types into strings using [`str`](#str), and decode from
the string protocol using [`from-string`](#from-string). Arrays are fully
supported, including nested arrays.
```
; decoding
(RESP.from-string \"+OK\\r\\n\") ; => (Success (Str @\"OK\"))
(RESP.from-string \":42\\r\\n\") ; => (Success (Integer 42))
(RESP.from-string \"$-1\\r\\n\") ; => (Success (Null))
; encoding
(str &(RESP.Str @\"hi\")) ; => \"$2\\r\\nhi\\r\\n\"
(str &(RESP.Integer 42)) ; => \":42\\r\\n\"
; pattern matching on responses
(match (Redis.get &r @\"key\")
(Result.Success resp)
(match resp
(RESP.Str s) (println* \"got: \" &s)
(RESP.Null) (println* \"not found\")
(RESP.Arr items) (println* \"array of \" &(Int.str (Array.length &items)))
_ (println* \"other\"))
(Result.Error e) (println* \"error: \" &e))
```
If you want your types to be supported when encoding, youll have to implement
the interface `to-redis`, the signature of which is `(Fn [a] RESP))`.")