object
redis
Redis client library with support for strings, keys, hashes, lists, sets, and sorted sets. Inspired by Sean Charles GNU Prolog Redis client.
logtalk_load(redis(loader))static, context_switching_calls
Command representation: Use the Redis command name as the functor of a compound term where the arguments are the command arguments.
Valid arguments: Atoms, integers, and floats. Always use atoms instead of double-quoted “strings”. This helps portability by not depending on the value of the
double_quotesflag.Wrapper predicates: The library provides convenient wrapper predicates for common Redis operations. For operations without a wrapper, use the generic
send/3predicate.
Public predicates
connect/1
Connect to a Redis server running on localhost using the default 6379 port.
staticconnect(Connection)connect(--ground) - oneconnect/3
Connect to a Redis server running on the given host and port.
staticconnect(Host,Port,Connection)connect(+atom,+integer,--ground) - onedisconnect/1
Disconnect from a Redis server.
staticdisconnect(Connection)disconnect(++ground) - onesend/3
Sends a request to the a Redis server and returns its reply.
staticsend(Connection,Request,Reply)send(++ground,++callable,--callable) - oneconsole/1
Sends a request to a Redis server running on localhost at the default 6379 port and prints the reply.
staticconsole(Request)console(++callable) - oneget/3
Gets the value of a key.
staticget(Connection,Key,Value)get(+ground,+atom,-atom) - oneset/4
Sets the value of a key.
staticset(Connection,Key,Value,Status)set(+ground,+atom,+ground,-atom) - oneappend/4
Appends a value to a key. Returns the length of the string after the append.
staticappend(Connection,Key,Value,Length)append(+ground,+atom,+ground,-integer) - onegetrange/5
Gets a substring of the string stored at a key.
staticgetrange(Connection,Key,Start,End,Substring)getrange(+ground,+atom,+integer,+integer,-atom) - onesetrange/5
Overwrites part of a string at a key starting at the specified offset. Returns the length of the string after modification.
staticsetrange(Connection,Key,Offset,Value,Length)setrange(+ground,+atom,+integer,+ground,-integer) - onestrlen/3
Gets the length of the value stored at a key.
staticstrlen(Connection,Key,Length)strlen(+ground,+atom,-integer) - onemget/3
Gets the values of multiple keys. Returns a list of values.
staticmget(Connection,Keys,Values)mget(+ground,+list(atom),-list) - onemset/3
Sets multiple key-value pairs. Pairs should be provided as a flat list [Key1, Value1, Key2, Value2, …].
staticmset(Connection,Pairs,Status)mset(+ground,+list,-atom) - oneincr/3
Increments the integer value of a key by one. Returns the value after increment.
staticincr(Connection,Key,Value)incr(+ground,+atom,-integer) - onedecr/3
Decrements the integer value of a key by one. Returns the value after decrement.
staticdecr(Connection,Key,Value)decr(+ground,+atom,-integer) - oneincrby/4
Increments the integer value of a key by the specified amount. Returns the value after increment.
staticincrby(Connection,Key,Increment,Value)incrby(+ground,+atom,+integer,-integer) - onedecrby/4
Decrements the integer value of a key by the specified amount. Returns the value after decrement.
staticdecrby(Connection,Key,Decrement,Value)decrby(+ground,+atom,+integer,-integer) - onedel/3
Deletes a key. Returns the number of keys removed.
staticdel(Connection,Key,Count)del(+ground,+atom,-integer) - oneexists/3
Checks if a key exists. Returns 1 if the key exists, 0 otherwise.
staticexists(Connection,Key,Exists)exists(+ground,+atom,-integer) - onekeys/3
Finds all keys matching a pattern. Returns a list of keys.
statickeys(Connection,Pattern,Keys)keys(+ground,+atom,-list) - onettl/3
Gets the time to live for a key in seconds. Returns -1 if the key has no expiry, -2 if the key does not exist.
staticttl(Connection,Key,Seconds)ttl(+ground,+atom,-integer) - oneexpire/4
Sets a timeout on a key in seconds. Returns 1 if the timeout was set, 0 if the key does not exist.
staticexpire(Connection,Key,Seconds,Result)expire(+ground,+atom,+integer,-integer) - onepersist/3
Removes the expiration from a key. Returns 1 if the timeout was removed, 0 if the key does not exist or has no timeout.
staticpersist(Connection,Key,Result)persist(+ground,+atom,-integer) - onerename/4
Renames a key. Returns status OK or error if the key does not exist.
staticrename(Connection,OldKey,NewKey,Status)rename(+ground,+atom,+atom,-atom) - onetype/3
Gets the type of the value stored at a key. Returns one of: string, list, set, zset, hash, stream, none.
statictype(Connection,Key,Type)type(+ground,+atom,-atom) - onehset/5
Sets a field in a hash. Returns 1 if a new field was created, 0 if the field was updated.
statichset(Connection,Key,Field,Value,Result)hset(+ground,+atom,+atom,+ground,-integer) - onehget/4
Gets the value of a field in a hash.
statichget(Connection,Key,Field,Value)hget(+ground,+atom,+atom,-ground) - onehgetall/3
Gets all fields and values in a hash. Returns a flat list of alternating fields and values.
statichgetall(Connection,Key,FieldsValues)hgetall(+ground,+atom,-list) - onehdel/4
Deletes a field from a hash. Returns the number of fields removed.
statichdel(Connection,Key,Field,Count)hdel(+ground,+atom,+atom,-integer) - onehexists/4
Checks if a field exists in a hash. Returns 1 if the field exists, 0 otherwise.
statichexists(Connection,Key,Field,Exists)hexists(+ground,+atom,+atom,-integer) - onehkeys/3
Gets all field names in a hash.
statichkeys(Connection,Key,Fields)hkeys(+ground,+atom,-list) - onehvals/3
Gets all values in a hash.
statichvals(Connection,Key,Values)hvals(+ground,+atom,-list) - onehlen/3
Gets the number of fields in a hash.
statichlen(Connection,Key,Count)hlen(+ground,+atom,-integer) - onelpush/4
Prepends a value to a list. Returns the length of the list after the push.
staticlpush(Connection,Key,Value,Length)lpush(+ground,+atom,+ground,-integer) - onerpush/4
Appends a value to a list. Returns the length of the list after the push.
staticrpush(Connection,Key,Value,Length)rpush(+ground,+atom,+ground,-integer) - onelpop/3
Removes and returns the first element of a list.
staticlpop(Connection,Key,Value)lpop(+ground,+atom,-ground) - onerpop/3
Removes and returns the last element of a list.
staticrpop(Connection,Key,Value)rpop(+ground,+atom,-ground) - onelrange/5
Gets a range of elements from a list. Indices are zero-based.
staticlrange(Connection,Key,Start,Stop,Elements)lrange(+ground,+atom,+integer,+integer,-list) - onellen/3
Gets the length of a list.
staticllen(Connection,Key,Length)llen(+ground,+atom,-integer) - onelrem/5
Removes elements from a list. Count > 0: remove from head, Count < 0: remove from tail, Count = 0: remove all. Returns the number of removed elements.
staticlrem(Connection,Key,Count,Value,Removed)lrem(+ground,+atom,+integer,+ground,-integer) - oneltrim/5
Trims a list to the specified range.
staticltrim(Connection,Key,Start,Stop,Status)ltrim(+ground,+atom,+integer,+integer,-atom) - onesadd/4
Adds a member to a set. Returns the number of elements added.
staticsadd(Connection,Key,Member,Count)sadd(+ground,+atom,+ground,-integer) - onesrem/4
Removes a member from a set. Returns the number of elements removed.
staticsrem(Connection,Key,Member,Count)srem(+ground,+atom,+ground,-integer) - onesmembers/3
Gets all members in a set.
staticsmembers(Connection,Key,Members)smembers(+ground,+atom,-list) - onesismember/4
Checks if a value is a member of a set. Returns 1 if the member exists, 0 otherwise.
staticsismember(Connection,Key,Member,IsMember)sismember(+ground,+atom,+ground,-integer) - onescard/3
Gets the number of members in a set.
staticscard(Connection,Key,Count)scard(+ground,+atom,-integer) - onezadd/5
Adds a member with a score to a sorted set. Returns the number of elements added.
staticzadd(Connection,Key,Score,Member,Count)zadd(+ground,+atom,+number,+ground,-integer) - onezrem/4
Removes a member from a sorted set. Returns the number of elements removed.
staticzrem(Connection,Key,Member,Count)zrem(+ground,+atom,+ground,-integer) - onezrange/5
Gets a range of members from a sorted set, ordered from lowest to highest score.
staticzrange(Connection,Key,Start,Stop,Members)zrange(+ground,+atom,+integer,+integer,-list) - onezrank/4
Gets the rank (index) of a member in a sorted set, ordered from lowest to highest score. Returns nil if the member does not exist.
staticzrank(Connection,Key,Member,Rank)zrank(+ground,+atom,+ground,-integer) - onezcard/3
Gets the number of members in a sorted set.
staticzcard(Connection,Key,Count)zcard(+ground,+atom,-integer) - onezscore/4
Gets the score of a member in a sorted set.
staticzscore(Connection,Key,Member,Score)zscore(+ground,+atom,+ground,-ground) - oneProtected predicates
(no local declarations; see entity ancestors if any)
Private predicates
(no local declarations; see entity ancestors if any)
Operators
(none)