Poco::Redis

class Command

File Information

Library: Redis
Package: Redis
Header: Poco/Redis/Command.h

Description

Helper class for creating commands. This class contains factory methods for commonly used Redis commands.

There are two ways of building commands:

  1. Use this class and the factory methods
  2. Use the Array or Command class and build the command using the add method or << operator.

For example:

Command cmd = Command::set("mykey", "Hello");

is the same as:

Array cmd;
cmd << "SET" << "mykey" << "Hello";

Inheritance

Direct Base Classes: Array

All Base Classes: Array

Member Summary

Member Functions: append, auth, blpop, brpop, brpoplpush, decr, del, discard, exec, exists, expire, get, hdel, hexists, hget, hgetall, hincrby, hkeys, hlen, hmget, hmset, hset, hstrlen, hvals, incr, keys, lindex, linsert, llen, lpop, lpush, lrange, lrem, lset, ltrim, mget, mset, multi, ping, rename, rpop, rpoplpush, rpush, sadd, scard, sdiff, sdiffstore, set, sinter, sinterstore, sismember, smembers, smove, spop, srandmember, srem, sunion, sunionstore

Inherited Functions: add, addRedisType, addSimpleString, begin, clear, end, get, getType, isNull, makeNull, operator <<, size, toString

Types Aliases

StringVec

using StringVec = std::vector < std::string >;

Constructors

Command

Command(
    const std::string & command
);

Creates a command.

Command

Command(
    const Command & copy
);

Creates a command by copying another one.

Destructor

~Command virtual

virtual ~Command();

Destroys the command.

Member Functions

append static

static Command append(
    const std::string & key,
    const std::string & value
);

Creates and returns an APPEND command.

auth static

static Command auth(
    const std::string & password
);

Creates and returns an AUTH command with the given password.

auth static

static Command auth(
    const std::string & username,
    const std::string & password
);

Creates and returns an AUTH command with the given password.

blpop static

static Command blpop(
    const StringVec & lists,
    Int64 timeout = 0
);

Creates and returns a BLPOP command.

brpop static

static Command brpop(
    const StringVec & lists,
    Int64 timeout = 0
);

Creates and returns a BRPOP command.

brpoplpush static

static Command brpoplpush(
    const std::string & sourceList,
    const std::string & destinationList,
    Int64 timeout = 0
);

Creates and returns a BRPOPLPUSH command.

decr static

static Command decr(
    const std::string & key,
    Int64 by = 0
);

Creates and returns an DECR or DECRBY command. Calls DECR when by is omitted or zero.

del static

static Command del(
    const std::string & key
);

Creates and returns an DEL command.

del static

static Command del(
    const StringVec & keys
);

Creates and returns an DEL command.

discard static

static Command discard();

Creates and returns a DISCARD command.

exec static

static Command exec();

Creates and returns a EXEC command.

exists static

static Command exists(
    const std::string & key
);

Creates and returns an EXISTS command.

expire static

static Command expire(
    const std::string & key,
    Int64 seconds
);

Creates and returns an EXPIRE command.

get static

static Command get(
    const std::string & key
);

Creates and returns an GET command.

hdel static

static Command hdel(
    const std::string & hash,
    const std::string & field
);

Creates and returns an HDEL command.

hdel static

static Command hdel(
    const std::string & hash,
    const StringVec & fields
);

Creates and returns an HDEL command.

hexists static

static Command hexists(
    const std::string & hash,
    const std::string & field
);

Creates and returns an HEXISTS command.

hget static

static Command hget(
    const std::string & hash,
    const std::string & field
);

Creates and returns an HGET command.

hgetall static

static Command hgetall(
    const std::string & hash
);

Creates and returns an HGETALL command.

hincrby static

static Command hincrby(
    const std::string & hash,
    const std::string & field,
    Int64 by = 1
);

Creates and returns an HINCRBY command.

hkeys static

static Command hkeys(
    const std::string & hash
);

Creates and returns an HKEYS command.

hlen static

static Command hlen(
    const std::string & hash
);

Creates and returns an HLEN command.

hmget static

static Command hmget(
    const std::string & hash,
    const StringVec & fields
);

Creates and returns an HMGET command.

hmset static

static Command hmset(
    const std::string & hash,
    std::map < std::string, std::string > & fields
);

Creates and returns a HMSET command.

hset static

static Command hset(
    const std::string & hash,
    const std::string & field,
    const std::string & value,
    bool create = true
);

Creates and returns an HSET or HSETNX (when create is false) command.

hset static

static Command hset(
    const std::string & hash,
    const std::string & field,
    Int64 value,
    bool create = true
);

Creates and returns an HSET or HSETNX (when create is false) command.

hstrlen static

static Command hstrlen(
    const std::string & hash,
    const std::string & field
);

Creates and returns an HSTRLEN command (Available for Redis 3.2).

hvals static

static Command hvals(
    const std::string & hash
);

Creates and returns an HVALS command.

incr static

static Command incr(
    const std::string & key,
    Int64 by = 0
);

Creates and returns an INCR or INCRBY command. Calls INCR when by is omitted or zero.

keys static

static Command keys(
    const std::string & pattern
);

Creates and returns a KEYS command.

lindex static

static Command lindex(
    const std::string & list,
    Int64 index = 0
);

Creates and returns a LINDEX command.

linsert static

static Command linsert(
    const std::string & list,
    bool before,
    const std::string & reference,
    const std::string & value
);

Creates and returns a LINSERT command.

llen static

static Command llen(
    const std::string & list
);

Creates and returns a LLEN command.

lpop static

static Command lpop(
    const std::string & list
);

Creates and returns a LPOP command.

lpush static

static Command lpush(
    const std::string & list,
    const std::string & value,
    bool create = true
);

Creates and returns a LPUSH or LPUSHX (when create is false) command.

lpush static

static Command lpush(
    const std::string & list,
    const StringVec & value,
    bool create = true
);

Creates and returns a LPUSH or LPUSHX (when create is false) command.

lrange static

static Command lrange(
    const std::string & list,
    Int64 start = 0,
    Int64 stop = - 1
);

Creates and returns a LRANGE command. When start and stop is omitted an LRANGE command will returned that returns all items of the list.

lrem static

static Command lrem(
    const std::string & list,
    Int64 count,
    const std::string & value
);

Creates and returns a LREM command.

lset static

static Command lset(
    const std::string & list,
    Int64 index,
    const std::string & value
);

Creates and returns a LSET command.

ltrim static

static Command ltrim(
    const std::string & list,
    Int64 start = 0,
    Int64 stop = - 1
);

Creates and returns a LTRIM command.

mget static

static Command mget(
    const StringVec & keys
);

Creates and returns a MGET command.

mset static

static Command mset(
    const std::map < std::string, std::string > & keyvalues,
    bool create = true
);

Creates and returns a MSET or MSETNX (when create is false) command.

multi static

static Command multi();

Creates and returns a MULTI command.

ping static

static Command ping();

Creates and returns a PING command.

rename static

static Command rename(
    const std::string & key,
    const std::string & newName,
    bool overwrite = true
);

Creates and returns a RENAME or RENAMENX when overwrite is false.

rpop static

static Command rpop(
    const std::string & list
);

Creates and returns a RPOP command.

rpoplpush static

static Command rpoplpush(
    const std::string & sourceList,
    const std::string & destinationList
);

Creates and returns a RPOPLPUSH command.

rpush static

static Command rpush(
    const std::string & list,
    const std::string & value,
    bool create = true
);

Creates and returns a RPUSH or RPUSHX (when create is false) command.

rpush static

static Command rpush(
    const std::string & list,
    const StringVec & value,
    bool create = true
);

Creates and returns a RPUSH or RPUSHX (when create is false) command.

sadd static

static Command sadd(
    const std::string & set,
    const std::string & value
);

Creates and returns a SADD command.

sadd static

static Command sadd(
    const std::string & set,
    const StringVec & values
);

Creates and returns a SADD command.

scard static

static Command scard(
    const std::string & set
);

Creates and returns a SCARD command.

sdiff static

static Command sdiff(
    const std::string & set1,
    const std::string & set2
);

Creates and returns a SDIFF command.Creates and returns

sdiff static

static Command sdiff(
    const std::string & set,
    const StringVec & sets
);

Creates and returns a SDIFF command.

sdiffstore static

static Command sdiffstore(
    const std::string & set,
    const std::string & set1,
    const std::string & set2
);

Creates and returns a SDIFFSTORE command.

sdiffstore static

static Command sdiffstore(
    const std::string & set,
    const StringVec & sets
);

Creates and returns a SDIFFSTORE command.

set static

static Command set(
    const std::string & key,
    const std::string & value,
    bool overwrite = true,
    const Poco::Timespan & expireTime = 0,
    bool create = true
);

Creates and returns a SET command to set the key with a value.

set static

static Command set(
    const std::string & key,
    Int64 value,
    bool overwrite = true,
    const Poco::Timespan & expireTime = 0,
    bool create = true
);

Creates and returns a SET command to set the key with a value.

sinter static

static Command sinter(
    const std::string & set1,
    const std::string & set2
);

Creates and returns a SINTER command.

sinter static

static Command sinter(
    const std::string & set,
    const StringVec & sets
);

Creates and returns a SINTER command.

sinterstore static

static Command sinterstore(
    const std::string & set,
    const std::string & set1,
    const std::string & set2
);

Creates and returns a SINTERSTORE command.

sinterstore static

static Command sinterstore(
    const std::string & set,
    const StringVec & sets
);

Creates and returns a SINTERSTORE command.

sismember static

static Command sismember(
    const std::string & set,
    const std::string & member
);

Creates and returns a SISMEMBER command.

smembers static

static Command smembers(
    const std::string & set
);

Creates and returns a SMEMBERS command.

smove static

static Command smove(
    const std::string & source,
    const std::string & destination,
    const std::string & member
);

Creates and returns a SMOVE command.

spop static

static Command spop(
    const std::string & set,
    Int64 count = 0
);

Creates and returns a SPOP command.

srandmember static

static Command srandmember(
    const std::string & set,
    Int64 count = 0
);

Creates and returns a SRANDMEMBER command.

srem static

static Command srem(
    const std::string & set,
    const std::string & member
);

Creates and returns a SREM command.

srem static

static Command srem(
    const std::string & set,
    const StringVec & members
);

Creates and returns a SREM command.

sunion static

static Command sunion(
    const std::string & set1,
    const std::string & set2
);

Creates and returns a SUNION command.

sunion static

static Command sunion(
    const std::string & set,
    const StringVec & sets
);

Creates and returns a SUNION command.

sunionstore static

static Command sunionstore(
    const std::string & set,
    const std::string & set1,
    const std::string & set2
);

Creates and returns a SUNIONSTORE command.

sunionstore static

static Command sunionstore(
    const std::string & set,
    const StringVec & sets
);

Creates and returns a SUNIONSTORE command.