PageRenderTime 19ms CodeModel.GetById 15ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/R/allValCMD.R

http://github.com/bwlewis/rredis
R | 104 lines | 84 code | 19 blank | 1 comment | 3 complexity | dd7565ebc3a8746226451bf301cd8b49 MD5 | raw file
  1# This file contains functions that operate on all kinds of Redis values.
  2
  3redisMulti <- function()
  4{
  5  .redisCmd(.raw('MULTI'))
  6}
  7
  8redisExec <- function()
  9{
 10  .redisCmd(.raw('EXEC'))
 11}
 12
 13redisDiscard <- function()
 14{
 15  .redisCmd(.raw('DISCARD'))
 16}
 17
 18redisWatch <- function(keys)
 19{
 20  cmd <- 'WATCH'
 21  keys <- as.list(keys)
 22  keys <- lapply(keys, charToRaw)
 23  do.call('.redisCmd', c(list(.raw(cmd)),keys))
 24}
 25
 26redisUnwatch <- function()
 27{
 28  cmd <- 'UNWATCH'
 29  do.call('.redisCmd', list(.raw(cmd)))
 30}
 31
 32redisExists <- function(key) 
 33{
 34  .redisCmd(.raw('EXISTS'), .raw(key)) == '1'
 35}
 36
 37redisDelete <- function(key) 
 38{
 39  keylist <- as.list(key)
 40  nkeys <- length(keylist)
 41  as.numeric(do.call('.redisCmd',lapply(c(list('DEL'),keylist),charToRaw)))
 42}
 43
 44redisType <- function(key) 
 45{
 46  .redisCmd(.raw('TYPE'), .raw(key))
 47}
 48
 49redisKeys <- function(pattern="*") 
 50{
 51  res <- .redisCmd(.raw('KEYS'), .raw(pattern))
 52  unlist(res)
 53}
 54
 55redisRandomKey <- function() 
 56{
 57  .redisCmd(.raw('RANDOMKEY'))
 58}
 59
 60redisRename <- function(old, new, NX=FALSE) 
 61{
 62  if (NX) cmd <- 'RENAMENX' else cmd <- 'RENAME'
 63  .redisCmd(.raw(cmd),.raw(old),.raw(new))
 64}
 65
 66redisPexpire <- function(key, milliseconds)
 67{
 68  .redisCmd(.raw('PEXPIRE'),.raw(key),.raw(as.character(milliseconds)))
 69}
 70
 71redisPexpireAt <- function(key, time)
 72{
 73  .redisCmd(.raw('PEXPIREAT'),.raw(key),.raw(as.character(time)))
 74}
 75
 76redisPTTL <- function(key)
 77{
 78  .redisCmd(.raw('PTTL'),.raw(key))
 79}
 80
 81redisPersist <- function(key)
 82{
 83  .redisCmd(.raw('PERSIST'),.raw(key))
 84}
 85
 86redisExpire <- function(key, seconds) 
 87{
 88  .redisCmd(.raw('EXPIRE'),.raw(key),.raw(as.character(seconds)))
 89}
 90
 91redisExpireAt <- function(key, time) 
 92{
 93  .redisCmd(.raw('EXPIREAT'),.raw(key),.raw(as.character(time)))
 94}
 95
 96redisTTL <- function(key) 
 97{
 98  .redisCmd(.raw('TTL'),.raw(key))
 99}
100
101redisMove <- function(key, dbindex) 
102{
103  .redisCmd(.raw('MOVE'),.raw(key),.raw(as.character(dbindex)))
104}