"A:B:..."
.
This is a common shorthand for representing Redis keys.\
u0000T\
u0000"
followed by Term in canonical form.
Reply is either a plain term (often a variable) or a term Value as Type
.
In the latter form, Type dictates how the Redis bulk
reply is translated to Prolog. The default equals to auto
,
i.e., as a number of the content satisfies the Prolog number syntax and
as an atom otherwise.
status(Atom)
Returned if the server replies with + Status
.
Atom is the textual value of Status converted to lower case,
e.g., status(ok)
or status(pong)
.nil
This atom is returned for a NIL/NULL value. Note
that if the reply is only nil
, redis/3 fails.
The nil
value may be embedded inside lists or maps.\
u0000T\
u0000"
it is supposed to be a Prolog term. Note that this intepretation means
it is not possible to read arbitrary binary blobs.nil
. If Reply
as a whole would be nil
the call fails.
Redis bulk replies are translated depending on the as
Type
as explained above.
bytes
(iso_latin_1
), utf8
and text
(the current locale translation).type_error(Type, String)
is raised.min_tagged_integer
and max_tagged_integer
, allowing the value to be used as a
dict key.auto(atom, number)
auto(atom,tagged_integer)
. This allows the value
to be used as a key for a SWI-Prolog dict.pairs
type can also be applied to a Redis array. In this case the array length
must be even. This notably allows fetching a Redis
hash as pairs using HGETALL
using version 2 of the
Redis protocol.pairs(AsKey, AsValue)
, but convert the resulting
pair list into a SWI-Prolog dict. AsKey must convert to a
valid dict key, i.e., an atom or tagged integer. See dict_key
.dict(dict_key, AsValue)
.Here are some simple examples
?- redis(default, set(a, 42), X). X = status("OK"). ?- redis(default, get(a), X). X = "42". ?- redis(default, get(a), X as integer). X = 42. ?- redis(default, get(a), X as float). X = 42.0. ?- redis(default, set(swipl:version, 8)). true. ?- redis(default, incr(swipl:version), X). X = 9.
redis_error(Code, String)