On this page:
redis-count-keys
redis-expire-at!
redis-expire-in!
redis-has-key?
redis-key-ttl
redis-key-type
redis-keys
redis-move-key!
redis-persist!
redis-random-key
redis-remove!
redis-rename!
redis-scan
redis-touch!
in-redis

10 Key Commands🔗ℹ

procedure

(redis-count-keys client key ...)  exact-nonnegative-integer?

  client : redis?
  key : redis-key/c
Returns how many of the given keys exist. Keys are counted as many times as they are provided.
Commands used by this function: EXISTS

procedure

(redis-expire-at! client key ms)  boolean?

  client : redis?
  key : redis-key/c
  ms : exact-nonnegative-integer?
Marks key so that it will expire at the UNIX timestamp represented by ms milliseconds. Returns #f if the key is not in the database.
Commands used by this function: PEXPIREAT

procedure

(redis-expire-in! client key ms)  boolean?

  client : redis?
  key : redis-key/c
  ms : exact-nonnegative-integer?
Marks key so that it will expire in ms milliseconds. Returns #f if the key is not in the database.
Commands used by this function: PEXPIRE

procedure

(redis-has-key? client key)  boolean?

  client : redis?
  key : redis-key/c
Returns #t when key is in the database.
Commands used by this function: EXISTS

procedure

(redis-key-ttl client key)

  (or/c 'missing 'persisted exact-nonnegative-integer?)
  client : redis?
  key : redis-key/c
Returns the number of milliseconds before key expires.

If key is not present on the server, then 'missing is returned.

If key exists but isn’t marked for expiration, then 'persisted is returned.
Commands used by this function: PTTL

procedure

(redis-key-type client key)  (or/c 'none redis-key-type/c)

  client : redis?
  key : redis-key/c
Returns key’s type.
Commands used by this function: TYPE

procedure

(redis-keys client pattern)  (listof bytes?)

  client : redis?
  pattern : redis-string/c
Returns a list of all the keys in the database that match the given pattern.
Commands used by this function: KEYS

procedure

(redis-move-key! client key db)  boolean?

  client : redis?
  key : redis-key/c
  db : (integer-in 0 16)
Move key from the current database into db.
Commands used by this function: MOVE

procedure

(redis-persist! client key)  boolean?

  client : redis?
  key : redis-key/c
Removes key’s expiration.
Commands used by this function: PERSIST

procedure

(redis-random-key client)  (or/c #f bytes?)

  client : redis?
Returns a random key from the database or #f if the database is empty.
Commands used by this function: RANDOMKEY

procedure

(redis-remove! client    
  key ...+    
  [#:async? async?])  exact-nonnegative-integer?
  client : redis?
  key : redis-key/c
  async? : boolean? = #f
Removes each key from the database and returns the number of keys that were removed.

When async? is #t the command returns immediately and the keys are removed asynchronously.
Commands used by this function: DEL, UNLINK

procedure

(redis-rename! client    
  src    
  dest    
  [#:unless-exists? unless-exists?])  boolean?
  client : redis?
  src : redis-key/c
  dest : redis-key/c
  unless-exists? : boolean? = #f
Renames src to dest.

If unless-exists? is #t, then the key is only renamed if a key named dest does not already exist.
Commands used by this function: RENAME

procedure

(redis-scan client    
  [#:cursor cursor    
  #:pattern pattern    
  #:limit limit    
  #:type type])  
exact-nonnegative-integer?
(listof redis-key/c)
  client : redis?
  cursor : exact-nonnegative-integer? = 0
  pattern : (or/c #f redis-string/c) = #f
  limit : (or/c #f exact-positive-integer?) = #f
  type : (or/c #f redis-key-type/c) = #f
Efficiently iterates through all the keys in the database.

The limit parameter serves as a hint for the implementation, but the server may return more items than limit per iteration.
Commands used by this function: SCAN

procedure

(redis-touch! client key ...+)  exact-nonnegative-integer?

  client : redis?
  key : redis-key/c
Updates the last modification time for each key and returns the number of keys that were updated.
Commands used by this function: TOUCH

procedure

(in-redis client)  (sequence/c  bytes?)

  client : redis?
Returns a sequence that can be used to efficiently iterate through the Redis database.

Any keyword arguments that are passed to this function will be forwarded to redis-scan.