11 List Commands
procedure
(redis-list-append! client key value)
→ (or/c #f exact-nonnegative-integer?) client : redis? key : redis-key/c value : redis-string/c
procedure
(redis-list-get client key) → redis-value/c
client : redis? key : redis-key/c
procedure
(redis-list-insert! client key value #:after pivot/after #:before pivot/before) → (or/c #f exact-nonnegative-integer?) client : redis? key : redis-key/c value : redis-string/c pivot/after : redis-string/c pivot/before : redis-string/c
If key is not a list, then #f is returned.
procedure
(redis-list-length client key) → exact-nonnegative-integer?
client : redis? key : redis-key/c
procedure
(redis-list-pop-left! client key ...+ [ #:block? block? #:timeout timeout]) → redis-value/c client : redis? key : redis-key/c block? : boolean? = #f timeout : exact-nonnegative-integer? = 0
; LPOP a (redis-list-pop-left! client "a")
When block? is #t, you can supply multiple keys to retrieve a value from. The function will wait up to timeout seconds for a value and the result will contain a list containing the popped key and its value.
; BLPOP a b 0 (redis-list-pop-left! client "a" "b" #:block? #t) ; BLPOP a b 1 (redis-list-pop-left! client "a" "b" #:block? #t #:timeout 1)
procedure
(redis-list-pop-right! client key ...+ [ #:dest dest #:block? block? #:timeout timeout]) → redis-value/c client : redis? key : redis-key/c dest : redis-key/c = #f block? : boolean? = #f timeout : exact-nonnegative-integer? = 0
; RPOP a (redis-list-pop-right! client "a")
When a dest is provided, the popped value is prepended to the list at dest. If multiple keys are provided along with a dest, then a contract error is raised.
; RPOPLPUSH a b (redis-list-pop-right! client "a" #:dest "b") ; BRPOPLPUSH a b 0 (redis-list-pop-right! client "a" #:dest "b" #:block? #t) ; BRPOPLPUSH a b 1 (redis-list-pop-right! client "a" #:dest "b" #:block? #t #:timeout 1)
When block? is #t, you can supply multiple keys to retrieve a value from or you can specify a dest into which the popped value should be prepended. The former operation maps to an BRPOP and the latter to a BRPOPLPUSH command.
; BRPOP a b 0 (redis-list-pop-right! client "a" "b" #:block? #t) ; BRPOP a b 1 (redis-list-pop-right! client "a" "b" #:block? #t #:timeout 1)
procedure
(redis-list-prepend! client key value)
→ (or/c #f exact-nonnegative-integer?) client : redis? key : redis-key/c value : redis-string/c
procedure
(redis-list-ref client key index) → redis-value/c
client : redis? key : redis-key/c index : exact-integer?
procedure
(redis-list-remove! client key count value)
→ exact-nonnegative-integer? client : redis? key : redis-key/c count : exact-integer? value : redis-string/c
procedure
(redis-list-set! client key index value) → boolean?
client : redis? key : redis-key/c index : exact-integer? value : redis-string/c
procedure
(redis-list-trim! client key [ #:start start #:stop stop]) → boolean? client : redis? key : redis-key/c start : exact-integer? = 0 stop : exact-integer? = -1
procedure
(redis-sublist client key [ #:start start #:stop stop]) → redis-value/c client : redis? key : redis-key/c start : exact-integer? = 0 stop : exact-integer? = -1