A Chicken Scheme Redis library.
Go to file
Daniel Ziltener 981144c743
Repository URL change
2023-11-24 22:47:51 +01:00
tests Repository URL change 2023-11-24 22:47:51 +01:00
.dir-locals.el In the beginning there was darkness 2022-10-25 16:59:41 +02:00
LICENSE In the beginning there was darkness 2022-10-25 16:59:41 +02:00
README.org In the beginning there was darkness 2022-10-25 17:01:32 +02:00
redis-impl.scm Repository URL change 2023-11-24 22:47:51 +01:00
redis.egg Repository URL change 2023-11-24 22:47:51 +01:00
redis.org Repository URL change 2023-11-24 22:47:51 +01:00
redis.release-info Repository URL change 2023-11-24 22:47:51 +01:00
redis.scm Repository URL change 2023-11-24 22:47:51 +01:00

README.org

Redis

Dependencies

SRFI Description
34 Exception Handling
35 Exception Types
69 Hash Tables
99 Extended Records
113 Sets and Bags
128 Comparators
133 Vectors
152 Strings
158 Generators and Accumulators

API

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.

(define-condition-type &redis-error &error
  redis-error?
  (redis-error-message redis-error-message))

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.

(redis-connect host port) Connects to a (hopefully) Redis server at host:port.

(redis-disconnect rconn) Disconnects from rconn which must be a redis-connection.

Running Commands

(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.

(redis-run-proc rconn proc . args) Calls proc with the output port of the rconn as current output port, optionally with args. Returns the parsed reply.

Supported Data Types

This Redis client supports all data types up to and including as specified in RESP3. Setting the protocol version with the HELLO command, however, is the user's responsibility.

Simple Strings

Simple strings start with + and are single-line.

+this is a simple string.

Simple Errors

Simple errors are like simple strings, but they start with a - instead.

-ERR unknown command 'helloworld'

Blob Strings

Blob strings are longer, potentially multi-line strings. Their sigil is $, followed by an integer designating the string length.

$7
chicken

Blob Errors

Analogous to simple errors, blob errors are just blob strings. Receiving one with this Redis library will raise an error.

!7
chicken

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.

=15
txt:Some string

Integers

Integers are sent to the client prefixed with :.

:180

Doubles

Doubles are prefixed with ,. The data type also allows inf for positive and -inf for negative infinity.

,1.23

Bignums

Bignums are prefixed with (.

(3492890328409238509324850943850943825024385

Booleans

True and false values are represented as #t and #f, just like in Scheme.

Null

The null type is encoded simply as _, and results in '().

Arrays

Arrays are marked with * followed by the number of entries, and get returned as srfi-133 vectors.

*3
:1
:2
:3

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.

%2
+first
:1
+second
:2

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)`.

~4
+orange
+apple
#t
#f

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.

This library returns two values in this case, the first value being the actual data reply from redis, the second one being the attributes.

About this egg

Source

The source is available at https://gitea.lyrion.ch/Chicken/redis.git.

Author

Daniel Ziltener

Version History

0.5 Initial Release

License

Copyright (C) 2022 Daniel Ziltener

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the <organization> nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.