scan_apply function

Iterate over keys using SCAN

Iterate over keys using SCAN

Support for iterating with SCAN. Note that this will generalise soon to support collecting output, SSCAN and other variants, etc.

scan_apply( con, callback, pattern = NULL, ..., count = NULL, type = "SCAN", key = NULL ) scan_del(con, pattern, count = NULL, type = "SCAN", key = NULL) scan_find(con, pattern, count = NULL, type = "SCAN", key = NULL)

Arguments

  • con: A redis_api object
  • callback: Function that takes a character vector of keys and does something useful to it. con$DEL is one option here to delete keys that match a pattern. Unlike R's *apply functions, callback is called for its side effects and its return values will be ignored.
  • pattern: Optional pattern to use.
  • ...: additional arguments passed through to callback. Note that if used, pattern must be provided (at least as NULL).
  • count: Optional step size (default is Redis' default which is 10)
  • type: Type of SCAN to run. Options are "SCAN" (the default), "HSCAN" (scan through keys of a hash), "SSCAN" (scan through elements of a set) and "ZSCAN" (scan though elements of a sorted set). If type is not "SCAN", then key must be provided. HSCAN and ZSCAN currently do not work usefully.
  • key: Key to use when running a hash, set or sorted set scan.

Details

The functions scan_del and scan_find are example functions that delete and find all keys corresponding to a given pattern.

  • Maintainer: Rich FitzJohn
  • License: GPL-2
  • Last published: 2023-11-30