This commit is contained in:
Daniel Ziltener 2024-04-09 14:05:23 +02:00
parent 981144c743
commit 5ed8812f67
Signed by: zilti
GPG key ID: B38976E82C9DAE42
6 changed files with 138 additions and 128 deletions

View file

@ -1,2 +1,3 @@
((scheme-mode . ((flymake-chicken-command-args . ("-X" "r7rs" "-R" "r7rs")) ((org-mode . ((geiser-scheme-implementation . chicken)))
(geiser-scheme . 'chicken)))) (scheme-mode . ((flymake-chicken-command-args . ("-X" "r7rs" "-R" "r7rs"))
(geiser-scheme-implementation . chicken))))

1
.envrc Normal file
View file

@ -0,0 +1 @@
use guix chicken chicken-test chicken-r7rs chicken-srfi-34 chicken-srfi-35 chicken-srfi-69 chicken-srfi-99 chicken-srfi-113 chicken-srfi-128 chicken-srfi-133 chicken-srfi-152 chicken-srfi-158 redis

View file

@ -2,6 +2,7 @@
(import r7rs (import r7rs
(chicken base) (chicken base)
(chicken port) (chicken port)
(chicken string)
(chicken io) (chicken io)
(chicken tcp) (chicken tcp)
(srfi 34) ;; Exception Handling (srfi 34) ;; Exception Handling
@ -28,15 +29,17 @@
;; Connection Management ;; 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 #!optional (protocol-version 1))~
;; Connects to a (hopefully) Redis server at =host:port=. ;; Connects to a (hopefully) Redis server at =host:port=, using the given protocol version. Defaults, like Redis itself, to version 1.
;; [[file:redis.org::*Connection Management][Connection Management:1]] ;; [[file:redis.org::*Connection Management][Connection Management:1]]
(define-record-type redis-connection #t #t input output) (define-record-type redis-connection #t #t input output)
(define (redis-connect host port) (define (redis-connect host port #!optional (protocol-version 1))
(let-values (((i o) (tcp-connect host port))) (let-values (((i o) (tcp-connect host port)))
(make-redis-connection i o))) (values (make-redis-connection i o)
(and (write-line (string-append "HELLO " (->string protocol-version)) o)
(redis-read-reply i)))))
;; Connection Management:1 ends here ;; Connection Management:1 ends here
@ -80,7 +83,7 @@
;; 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]].
;; #+name: redis-read-reply ;; #+name: redis-read-reply

View file

@ -7,7 +7,7 @@
(synopsis "A Redis client library for Chicken Scheme") (synopsis "A Redis client library for Chicken Scheme")
(category db) (category db)
(license "BSD") (license "BSD")
(version "0.5") (version "0.6")
(dependencies r7rs srfi-34 srfi-35 srfi-69 srfi-99 srfi-113 srfi-128 srfi-133 srfi-152 srfi-158) (dependencies r7rs srfi-34 srfi-35 srfi-69 srfi-99 srfi-113 srfi-128 srfi-133 srfi-152 srfi-158)
(test-dependencies test) (test-dependencies test)

View file

@ -82,6 +82,7 @@
(import r7rs (import r7rs
(chicken base) (chicken base)
(chicken port) (chicken port)
(chicken string)
(chicken io) (chicken io)
(chicken tcp) (chicken tcp)
(srfi 34) ;; Exception Handling (srfi 34) ;; Exception Handling
@ -111,14 +112,16 @@ This library defines an SRFI-35 exception type ~&redis-error~ that gets raised w
** Connection Management ** 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 #!optional (protocol-version 1))~
Connects to a (hopefully) Redis server at =host:port=. Connects to a (hopefully) Redis server at =host:port=, using the given protocol version. Defaults, like Redis itself, to version 1.
#+begin_src scheme :tangle redis-impl.scm :exports none #+begin_src scheme :tangle redis-impl.scm :exports none
(define-record-type redis-connection #t #t input output) (define-record-type redis-connection #t #t input output)
(define (redis-connect host port) (define (redis-connect host port #!optional (protocol-version 1))
(let-values (((i o) (tcp-connect host port))) (let-values (((i o) (tcp-connect host port)))
(make-redis-connection i o))) (values (make-redis-connection i o)
(and (write-line (string-append "HELLO " (->string protocol-version)) o)
(redis-read-reply i)))))
#+end_src #+end_src
~(redis-disconnect rconn)~ ~(redis-disconnect rconn)~
@ -156,7 +159,7 @@ Calls =proc= with the output port of the =rconn= as current output port, optiona
** 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]].
#+name: redis-read-reply #+name: redis-read-reply
#+begin_src scheme :tangle redis-impl.scm :exports none #+begin_src scheme :tangle redis-impl.scm :exports none
@ -567,6 +570,7 @@ Daniel Ziltener
** Version History ** Version History
#+name: version-history #+name: version-history
| 0.6 | Easier Protocol Version Setting |
| 0.5 | Initial Release | | 0.5 | Initial Release |
#+name: gen-releases #+name: gen-releases

View file

@ -2,5 +2,6 @@
;; -*- Scheme -*- ;; -*- Scheme -*-
(repo git "https://gitea.lyrion.ch/Chicken/redis.git") (repo git "https://gitea.lyrion.ch/Chicken/redis.git")
(uri targz "https://gitea.lyrion.ch/Chicken/redis/archive/{egg-release}.tar.gz") (uri targz "https://gitea.lyrion.ch/Chicken/redis/archive/{egg-release}.tar.gz")
(release "0.6") ;; Easier Protocol Version Setting
(release "0.5") ;; Initial Release (release "0.5") ;; Initial Release
;; Version History:3 ends here ;; Version History:3 ends here