Repository URL change
This commit is contained in:
parent
01dc69a6b4
commit
981144c743
6 changed files with 26 additions and 123 deletions
129
redis-impl.scm
129
redis-impl.scm
|
@ -16,7 +16,7 @@
|
||||||
)
|
)
|
||||||
;; API:2 ends here
|
;; API:2 ends here
|
||||||
|
|
||||||
|
;; Exceptions
|
||||||
;; This library defines an SRFI-35 exception type ~&redis-error~ that gets raised when Redis returns an error. The exception type has a single field called ~redis-error-message~ containing the error message returned by Redis.
|
;; This library defines an SRFI-35 exception type ~&redis-error~ that gets raised when Redis returns an error. The exception type has a single field called ~redis-error-message~ containing the error message returned by Redis.
|
||||||
|
|
||||||
;; [[file:redis.org::*Exceptions][Exceptions:1]]
|
;; [[file:redis.org::*Exceptions][Exceptions:1]]
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
(redis-error-message redis-error-message))
|
(redis-error-message redis-error-message))
|
||||||
;; Exceptions:1 ends here
|
;; Exceptions:1 ends here
|
||||||
|
|
||||||
|
;; Connection Management
|
||||||
;; This egg currently uses a simple TCP connection without any "bells and whistles". The two ports are kept in a record of type =redis-connection= in the fields ~input~ and ~output~.
|
;; This egg currently uses a simple TCP connection without any "bells and whistles". The two ports are kept in a record of type =redis-connection= in the fields ~input~ and ~output~.
|
||||||
|
|
||||||
;; ~(redis-connect host port)~
|
;; ~(redis-connect host port)~
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
(tcp-abandon-port (redis-connection-output rconn)))
|
(tcp-abandon-port (redis-connection-output rconn)))
|
||||||
;; Connection Management:2 ends here
|
;; Connection Management:2 ends here
|
||||||
|
|
||||||
|
;; Running Commands
|
||||||
|
|
||||||
;; ~(redis-run rconn command . args)~
|
;; ~(redis-run rconn command . args)~
|
||||||
;; Uses connection =rconn= to run =command= with =args=. The args will be appended to the command, space-separated. Returns the parsed reply.
|
;; Uses connection =rconn= to run =command= with =args=. The args will be appended to the command, space-separated. Returns the parsed reply.
|
||||||
|
@ -78,10 +78,7 @@
|
||||||
(redis-read-reply in)))
|
(redis-read-reply in)))
|
||||||
;; Running Commands:2 ends here
|
;; Running Commands:2 ends here
|
||||||
|
|
||||||
|
;; Supported Data Types
|
||||||
|
|
||||||
|
|
||||||
;; ** Supported Data Types
|
|
||||||
|
|
||||||
;; This Redis client supports all data types up to and including as specified in [[https://github.com/antirez/RESP3/blob/master/spec.md][RESP3]]. Setting the protocol version with the =HELLO= command, however, is the user's responsibility.
|
;; This Redis client supports all data types up to and including as specified in [[https://github.com/antirez/RESP3/blob/master/spec.md][RESP3]]. Setting the protocol version with the =HELLO= command, however, is the user's responsibility.
|
||||||
|
|
||||||
|
@ -108,9 +105,7 @@
|
||||||
((#\|) (read-redis-with-attributes port)))))
|
((#\|) (read-redis-with-attributes port)))))
|
||||||
;; redis-read-reply ends here
|
;; redis-read-reply ends here
|
||||||
|
|
||||||
|
;; Simple Strings
|
||||||
|
|
||||||
;; *** Simple Strings
|
|
||||||
;; Simple strings start with ~+~ and are single-line.
|
;; Simple strings start with ~+~ and are single-line.
|
||||||
|
|
||||||
;; #+name: read-redis-simple-string-example
|
;; #+name: read-redis-simple-string-example
|
||||||
|
@ -126,23 +121,7 @@
|
||||||
(read-line port)))
|
(read-line port)))
|
||||||
;; read-redis-simple-string ends here
|
;; read-redis-simple-string ends here
|
||||||
|
|
||||||
|
;; Blob Strings
|
||||||
|
|
||||||
;; #+RESULTS: simple-string-test
|
|
||||||
;; : -- testing Simple strings ----------------------------------------------------
|
|
||||||
;; : +this is a simple string. ............................................ [ PASS]
|
|
||||||
;; : 1 test completed in 0.0 seconds.
|
|
||||||
;; : 1 out of 1 (100%) test passed.
|
|
||||||
;; : -- done testing Simple strings -----------------------------------------------
|
|
||||||
|
|
||||||
;; *** Simple Errors
|
|
||||||
;; Simple errors are like simple strings, but they start with a ~-~ instead.
|
|
||||||
|
|
||||||
;; #+begin_example
|
|
||||||
;; -ERR unknown command 'helloworld'
|
|
||||||
;; #+end_example
|
|
||||||
|
|
||||||
;; *** Blob Strings
|
|
||||||
;; Blob strings are longer, potentially multi-line strings. Their sigil is ~$~, followed by an integer designating the string length.
|
;; Blob strings are longer, potentially multi-line strings. Their sigil is ~$~, followed by an integer designating the string length.
|
||||||
|
|
||||||
;; #+begin_example
|
;; #+begin_example
|
||||||
|
@ -164,33 +143,7 @@
|
||||||
str))
|
str))
|
||||||
;; read-redis-blob-string ends here
|
;; read-redis-blob-string ends here
|
||||||
|
|
||||||
|
;; Integers
|
||||||
|
|
||||||
;; #+RESULTS:
|
|
||||||
;; : -- testing Blob strings ------------------------------------------------------
|
|
||||||
;; : $10
|
|
||||||
;; : helloworld ...................................................... [ PASS]
|
|
||||||
;; : 1 test completed in 0.0 seconds.
|
|
||||||
;; : 1 out of 1 (100%) test passed.
|
|
||||||
;; : -- done testing Blob strings -------------------------------------------------
|
|
||||||
|
|
||||||
;; *** Blob Errors
|
|
||||||
;; Analogous to simple errors, blob errors are just blob strings. Receiving one with this Redis library will raise an error.
|
|
||||||
|
|
||||||
;; #+begin_example
|
|
||||||
;; !7
|
|
||||||
;; chicken
|
|
||||||
;; #+end_example
|
|
||||||
|
|
||||||
;; *** Verbatim Strings
|
|
||||||
;; This is exactly like the Blob string type, but the initial byte is = instead of $. Moreover the first three bytes provide information about the format of the following string, which can be txt for plain text, or mkd for markdown. This library treats verbatim strings exactly like blob strings and won't split off the format info.
|
|
||||||
|
|
||||||
;; #+begin_example
|
|
||||||
;; =15
|
|
||||||
;; txt:Some string
|
|
||||||
;; #+end_example
|
|
||||||
|
|
||||||
;; *** Integers
|
|
||||||
;; Integers are sent to the client prefixed with ~:~.
|
;; Integers are sent to the client prefixed with ~:~.
|
||||||
|
|
||||||
;; #+begin_example
|
;; #+begin_example
|
||||||
|
@ -208,16 +161,7 @@
|
||||||
(string->number elem))))
|
(string->number elem))))
|
||||||
;; read-redis-number ends here
|
;; read-redis-number ends here
|
||||||
|
|
||||||
|
;; Booleans
|
||||||
|
|
||||||
;; #+RESULTS:
|
|
||||||
;; : -- testing Bignums -----------------------------------------------------------
|
|
||||||
;; : (3492890328409238509324850943850943825024385 ......................... [ PASS]
|
|
||||||
;; : 1 test completed in 0.0 seconds.
|
|
||||||
;; : 1 out of 1 (100%) test passed.
|
|
||||||
;; : -- done testing Bignums ------------------------------------------------------
|
|
||||||
|
|
||||||
;; *** Booleans
|
|
||||||
;; True and false values are represented as ~#t~ and ~#f~, just like in Scheme.
|
;; True and false values are represented as ~#t~ and ~#f~, just like in Scheme.
|
||||||
|
|
||||||
;; #+name: read-redis-bool
|
;; #+name: read-redis-bool
|
||||||
|
@ -228,17 +172,7 @@
|
||||||
(string=? (read-line port) "t")))
|
(string=? (read-line port) "t")))
|
||||||
;; read-redis-bool ends here
|
;; read-redis-bool ends here
|
||||||
|
|
||||||
|
;; Null
|
||||||
|
|
||||||
;; #+RESULTS:
|
|
||||||
;; : -- testing Booleans ----------------------------------------------------------
|
|
||||||
;; : #t ................................................................... [ PASS]
|
|
||||||
;; : #f ................................................................... [ PASS]
|
|
||||||
;; : 2 tests completed in 0.0 seconds.
|
|
||||||
;; : 2 out of 2 (100%) tests passed.
|
|
||||||
;; : -- done testing Booleans -----------------------------------------------------
|
|
||||||
|
|
||||||
;; *** Null
|
|
||||||
;; The null type is encoded simply as ~_~, and results in ~'()~.
|
;; The null type is encoded simply as ~_~, and results in ~'()~.
|
||||||
|
|
||||||
;; #+name: read-redis-null
|
;; #+name: read-redis-null
|
||||||
|
@ -249,16 +183,7 @@
|
||||||
(read-line port) '()))
|
(read-line port) '()))
|
||||||
;; read-redis-null ends here
|
;; read-redis-null ends here
|
||||||
|
|
||||||
|
;; Arrays
|
||||||
|
|
||||||
;; #+RESULTS:
|
|
||||||
;; : -- testing Null --------------------------------------------------------------
|
|
||||||
;; : _ .................................................................... [ PASS]
|
|
||||||
;; : 1 test completed in 0.0 seconds.
|
|
||||||
;; : 1 out of 1 (100%) test passed.
|
|
||||||
;; : -- done testing Null ---------------------------------------------------------
|
|
||||||
|
|
||||||
;; *** Arrays
|
|
||||||
;; Arrays are marked with ~*~ followed by the number of entries, and get returned as srfi-133 vectors.
|
;; Arrays are marked with ~*~ followed by the number of entries, and get returned as srfi-133 vectors.
|
||||||
|
|
||||||
;; #+begin_example
|
;; #+begin_example
|
||||||
|
@ -282,16 +207,7 @@
|
||||||
vec))
|
vec))
|
||||||
;; read-redis-array ends here
|
;; read-redis-array ends here
|
||||||
|
|
||||||
|
;; Maps
|
||||||
|
|
||||||
;; #+RESULTS:
|
|
||||||
;; : -- testing Arrays ------------------------------------------------------------
|
|
||||||
;; : *3:1:2:3 ............................................................. [ PASS]
|
|
||||||
;; : 1 test completed in 0.0 seconds.
|
|
||||||
;; : 1 out of 1 (100%) test passed.
|
|
||||||
;; : -- done testing Arrays -------------------------------------------------------
|
|
||||||
|
|
||||||
;; *** Maps
|
|
||||||
;; Maps are represented exactly as arrays, but instead of using the ~*~ byte, the encoded value starts with a ~%~ byte. Moreover the number of following elements must be even. Maps represent a sequence of field-value items, basically what we could call a dictionary data structure, or in other terms, an hash. They get returned as srfi-69 hash tables.
|
;; Maps are represented exactly as arrays, but instead of using the ~*~ byte, the encoded value starts with a ~%~ byte. Moreover the number of following elements must be even. Maps represent a sequence of field-value items, basically what we could call a dictionary data structure, or in other terms, an hash. They get returned as srfi-69 hash tables.
|
||||||
|
|
||||||
;; #+begin_example
|
;; #+begin_example
|
||||||
|
@ -316,17 +232,7 @@
|
||||||
ht))
|
ht))
|
||||||
;; read-redis-map ends here
|
;; read-redis-map ends here
|
||||||
|
|
||||||
|
;; Sets
|
||||||
|
|
||||||
;; #+RESULTS:
|
|
||||||
;; : -- testing Maps --------------------------------------------------------------
|
|
||||||
;; : (hash-table-ref ht "first") .......................................... [ PASS]
|
|
||||||
;; : (hash-table-ref ht "second") ......................................... [ PASS]
|
|
||||||
;; : 2 tests completed in 0.001 seconds.
|
|
||||||
;; : 2 out of 2 (100%) tests passed.
|
|
||||||
;; : -- done testing Maps ---------------------------------------------------------
|
|
||||||
|
|
||||||
;; *** Sets
|
|
||||||
;; Sets are exactly like the Array type, but the first byte is ~~~ instead of ~*~. They get returned as srfi-113 sets.
|
;; Sets are exactly like the Array type, but the first byte is ~~~ instead of ~*~. They get returned as srfi-113 sets.
|
||||||
;; Additionally, there is a parameter defined, =redis-set-comparator=, that specifies the default comparator to be used for sets. It defaults to `(make-default-comparator)`.
|
;; Additionally, there is a parameter defined, =redis-set-comparator=, that specifies the default comparator to be used for sets. It defaults to `(make-default-comparator)`.
|
||||||
|
|
||||||
|
@ -359,16 +265,7 @@
|
||||||
s))
|
s))
|
||||||
;; read-redis-set ends here
|
;; read-redis-set ends here
|
||||||
|
|
||||||
|
;; Attributes
|
||||||
|
|
||||||
;; #+RESULTS:
|
|
||||||
;; : -- testing Sets --------------------------------------------------------------
|
|
||||||
;; : ~4+orange+apple#t#f .................................................. [ PASS]
|
|
||||||
;; : 1 test completed in 0.001 seconds.
|
|
||||||
;; : 1 out of 1 (100%) test passed.
|
|
||||||
;; : -- done testing Sets ---------------------------------------------------------
|
|
||||||
|
|
||||||
;; *** Attributes
|
|
||||||
;; The attribute type is exactly like the Map type, but instead of the ~%~ first byte, the ~|~ byte is used. Attributes describe a dictionary exactly like the Map type, however the client should not consider such a dictionary part of the reply, but just auxiliary data that is used in order to augment the reply.
|
;; The attribute type is exactly like the Map type, but instead of the ~%~ first byte, the ~|~ byte is used. Attributes describe a dictionary exactly like the Map type, however the client should not consider such a dictionary part of the reply, but just auxiliary data that is used in order to augment the reply.
|
||||||
|
|
||||||
;; This library returns two values in this case, the first value being the actual data reply from redis, the second one being the attributes.
|
;; This library returns two values in this case, the first value being the actual data reply from redis, the second one being the attributes.
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
;; About this egg
|
||||||
|
|
||||||
|
|
||||||
;; [[file:redis.org::*About this egg][About this egg:1]]
|
;; [[file:redis.org::*About this egg][About this egg:1]]
|
||||||
;; -*- Scheme -*-
|
;; -*- Scheme -*-
|
||||||
((author "Daniel Ziltener")
|
((author "Daniel Ziltener")
|
||||||
|
|
|
@ -244,7 +244,7 @@ chicken
|
||||||
<<prep-test>>
|
<<prep-test>>
|
||||||
<<read-redis-blob-string>>
|
<<read-redis-blob-string>>
|
||||||
(test-group "Blob strings"
|
(test-group "Blob strings"
|
||||||
(test "$10helloworld"
|
(test "$10\r\nhelloworld"
|
||||||
"helloworld"
|
"helloworld"
|
||||||
(with-input-from-string "10\r\nhelloworld\r\n" read-redis-blob-string)))
|
(with-input-from-string "10\r\nhelloworld\r\n" read-redis-blob-string)))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
@ -558,7 +558,7 @@ This library returns two values in this case, the first value being the actual d
|
||||||
|
|
||||||
** Source
|
** Source
|
||||||
|
|
||||||
The source is available at [[https://gitea.lyrion.ch/zilti/redis.git]].
|
The source is available at [[https://gitea.lyrion.ch/Chicken/redis.git]].
|
||||||
|
|
||||||
** Author
|
** Author
|
||||||
|
|
||||||
|
@ -582,8 +582,8 @@ Daniel Ziltener
|
||||||
|
|
||||||
#+begin_src scheme :noweb yes :tangle redis.release-info :exports none
|
#+begin_src scheme :noweb yes :tangle redis.release-info :exports none
|
||||||
;; -*- Scheme -*-
|
;; -*- Scheme -*-
|
||||||
(repo git "https://gitea.lyrion.ch/zilti/redis.git")
|
(repo git "https://gitea.lyrion.ch/Chicken/redis.git")
|
||||||
(uri targz "https://gitea.lyrion.ch/zilti/redis/archive/{egg-release}.tar.gz")
|
(uri targz "https://gitea.lyrion.ch/Chicken/redis/archive/{egg-release}.tar.gz")
|
||||||
<<gen-releases()>>
|
<<gen-releases()>>
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
;; [[file:redis.org::*Version History][Version History:3]]
|
;; [[file:redis.org::*Version History][Version History:3]]
|
||||||
;; -*- Scheme -*-
|
;; -*- Scheme -*-
|
||||||
(repo git "https://gitea.lyrion.ch/zilti/redis.git")
|
(repo git "https://gitea.lyrion.ch/Chicken/redis.git")
|
||||||
(uri targz "https://gitea.lyrion.ch/zilti/redis/archive/{egg-release}.tar.gz")
|
(uri targz "https://gitea.lyrion.ch/Chicken/redis/archive/{egg-release}.tar.gz")
|
||||||
(release "0.5") ;; Initial Release
|
(release "0.5") ;; Initial Release
|
||||||
;; Version History:3 ends here
|
;; Version History:3 ends here
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
;; API
|
||||||
|
|
||||||
|
|
||||||
;; [[file:redis.org::*API][API:1]]
|
;; [[file:redis.org::*API][API:1]]
|
||||||
(define-library (redis)
|
(define-library (redis)
|
||||||
(import (chicken base))
|
(import (chicken base))
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
(with-input-from-string "180\r\n" read-redis-number)))
|
(with-input-from-string "180\r\n" read-redis-number)))
|
||||||
;; Integers:2 ends here
|
;; Integers:2 ends here
|
||||||
|
|
||||||
|
;; Bignums
|
||||||
;; Bignums are prefixed with ~(~.
|
;; Bignums are prefixed with ~(~.
|
||||||
|
|
||||||
;; #+begin_example
|
;; #+begin_example
|
||||||
|
|
Loading…
Reference in a new issue