Mojo::R...Database(3)
๐ NAME ๐
Mojo::Redis::Database โ Execute basic redis commands ๐
(yeah bestie, this is the Mojo::R...Database(3) page from the User Contributed Perl Documentation, section 3 โ the title got truncated in the header but it's this one, ikyk) โจ
๐ธ SYNOPSIS ๐ธ
okay so here's the whole vibe from the jump:
use Mojo::Redis;
my $redis = Mojo::Redis->new;
my $db = $redis->db;
# Blocking
say "foo=" .$db->get("foo");
# Non-blocking
$db->get(foo => sub { my ($db, $res) = @_; say "foo=$res" });
# Promises
$db->get_p("foo")->then(sub { my ($res) = @_; say "foo=$res" });
so you got your blocking era, your non-blocking era, and your promises era โ pick your fighter, all three are valid ๐
and if you wanna see a whole Mojolicious app doing this for real, go look at <https://github.com/jhthorsen/mojo-redis/blob/master/examples/twitter.pl> โ that's the example application, go be nosy ๐ฆ
๐ฆ DESCRIPTION ๐ฆ
Mojo::Redis::Database is the one with the methods for sending and receiving structured data to the Redis server. that's the whole job. that's what she does. and she does it well ๐ซถ
โจ ATTRIBUTES โจ
๐ redis
$conn = $db->redis;
$db = $db->redis(Mojo::Redis->new);
this bad boy holds a Mojo::Redis object โ the one that's used to create the connections that actually talk to Redis. so like, it's the connection-maker-holder. the main character of connection logistics, lowkey ๐
๐ METHODS ๐
๐ append
$int = $db->append($key, $value);
$db = $db->append($key, $value, sub { my ($db, $err, $int) = @_ });
$promise = $db->append_p($key, $value);
Append a value to a key. that's it, that's the tweet.
See <https://redis.io/commands/append> for more information.
๐ bgrewriteaof
$ok = $db->bgrewriteaof;
$db = $db->bgrewriteaof(sub { my ($db, $err, $ok) = @_ });
$promise = $db->bgrewriteaof_p;
Asynchronously rewrite the append-only file. async girlie behavior fr fr โจ
See <https://redis.io/commands/bgrewriteaof> for more information.
๐ bgsave
$ok = $db->bgsave;
$db = $db->bgsave(sub { my ($db, $err, $ok) = @_ });
$promise = $db->bgsave_p;
Asynchronously save the dataset to disk. also asynchronous, also slaying ๐พ
See <https://redis.io/commands/bgsave> for more information.
๐ bitcount
$int = $db->bitcount($key, [start end]);
$db = $db->bitcount($key, [start end], sub { my ($db, $err, $int) = @_ });
$promise = $db->bitcount_p($key, [start end]);
Count set bits in a string. bits! counted! ๐
See <https://redis.io/commands/bitcount> for more information.
๐ bitfield
$res = $db->bitfield($key, [GET type offset], [SET type offset value], [INCRBY type offset increment], [OVERFLOW WRAP|SAT|FAIL]);
$db = $db->bitfield($key, [GET type offset], [SET type offset value], [INCRBY type offset increment], [OVERFLOW WRAP|SAT|FAIL], sub { my ($db, $err, $res) = @_ });
$promise = $db->bitfield_p($key, [GET type offset], [SET type offset value], [INCRBY typeoffset increment], [OVERFLOW WRAP|SAT|FAIL]);
Perform arbitrary bitfield integer operations on strings. arbitrary! integer! operations! she's giving math major ๐โจ
heads up bestie: if you're copying the promise version, yes, that last arg line inbitfield_preally does say[INCRBY typeoffset increment]โ that's how it's written here, don't come for me, I'm just the messenger ๐
See <https://redis.io/commands/bitfield> for more information.
๐ bitop
$int = $db->bitop($operation, $destkey, $key [key ...]);
$db = $db->bitop($operation, $destkey, $key [key ...], sub { my ($db, $err, $int) = @_ });
$promise = $db->bitop_p($operation, $destkey, $key [key ...]);
Perform bitwise operations between strings. strings getting bitwise, iconic behavior ๐ฅ
See <https://redis.io/commands/bitop> for more information.
๐ bitpos
$int = $db->bitpos($key, $bit, [start], [end]);
$db = $db->bitpos($key, $bit, [start], [end], sub { my ($db, $err, $int) = @_ });
$promise = $db->bitpos_p($key, $bit, [start], [end]);
Find first bit set or clear in a string. first! bit! found! ๐
See <https://redis.io/commands/bitpos> for more information.
๐ blpop
$db = $db->blpop($key [key ...], $timeout, sub { my ($db, $val, $key) = @_ });
$promise = $db->blpop_p($key [key ...], $timeout);
Remove and get the first element in a list, or block until one is available. so she'll wait. patiently. for you. ๐ฅบ
See <https://redis.io/commands/blpop> for more information.
๐ brpop
$db = $db->brpop($key [key ...], $timeout, sub { my ($db, $val, $key) = @_ });
$promise = $db->brpop_p($key [key ...], $timeout);
Remove and get the last element in a list, or block until one is available. same energy, opposite end ๐
See <https://redis.io/commands/brpop> for more information.
๐ brpoplpush
$db = $db->brpoplpush($source, $destination, $timeout, sub { my ($db, $err, $array_ref) = @_ });
$promise = $db->brpoplpush_p($source, $destination, $timeout);
Pop a value from a list, push it to another list and return it; or block until one is available. she's moving things around, it's giving relocation era ๐ฆ
See <https://redis.io/commands/brpoplpush> for more information.
๐ bzpopmax
$db = $db->bzpopmax($key [key ...], $timeout, sub { my ($db, $err, $array_ref) = @_ });
$promise = $db->bzpopmax_p($key [key ...], $timeout);
Remove and return the member with the highest score from one or more sorted sets, or block until one is available. highest score wins, main character energy ๐
See <https://redis.io/commands/bzpopmax> for more information.
๐ bzpopmin
$db = $db->bzpopmin($key [key ...], $timeout, sub { my ($db, $err, $array_ref) = @_ });
$promise = $db->bzpopmin_p($key [key ...], $timeout);
Remove and return the member with the lowest score from one or more sorted sets, or block until one is available. lowkey champion ๐ฅ
See <https://redis.io/commands/bzpopmin> for more information.
๐ call
$res = $db->call($command => @args);
$db = $db->call($command => @args, sub { my ($db, $err, $res) = @_; });
Same as "call_p", but either blocks or passes the result into a callback. choose your adventure ๐ข
๐ call_p
$promise = $db->call_p($command => @args);
$promise = $db->call_p(GET => "some:key");
Used to send a custom command to the Redis server. yes you can just. send whatever. custom command, custom vibes ๐ง
๐ client
$res = $db->client(@args);
$db = $db->client(@args, sub { my ($db, $err, $res) = @_ });
$promise = $db->client_p(@args);
Run a "CLIENT" command on the server. and @args can be any of these lil options:
KILL [ip:port] [ID client-id] [TYPE normal|master|slave|pubsub] [ADDR ip:port] [SKIPME yes/no]LISTGETNAMEPAUSE timeoutREPLY [ON|OFF|SKIP]SETNAME connection-name
See <https://redis.io/commands#server> for more information.
๐ connection
$non_blocking_connection = $db->connection(0);
$blocking_connection = $db->connection(1);
Returns a Mojo::Redis::Connection object. The default is to return a connection suitable for non-blocking methods, but passing in a true value will return the connection used for blocking methods. so 0 = non-blocking girlie, truthy = blocking girlie, no in-between ๐ซถ
# Blocking
my $res = $db->get("some:key");
# Non-blocking
$db->get_p("some:key");
$db->get("some:key", sub { ... });
๐ cluster
$res = $db->cluster(@args);
$db = $db->cluster(@args, sub { my ($db, $err, $res) = @_ });
$promise = $db->cluster_p(@args);
Used to execute cluster commands. cluster era!! ๐ซง
See <https://redis.io/commands#cluster> for more information.
๐ command
$array_ref = $db->command(@args);
$db = $db->command(@args, sub { my ($db, $err, $array_ref) = @_ });
$promise = $db->command_p(@args);
Get array of Redis command details. the details!! and @args can be:
- empty list
COUNTGETKEYSINFO command-name [command-name]
See <https://redis.io/commands/command> for more information.
๐ dbsize
$int = $db->dbsize;
$db = $db->dbsize(sub { my ($db, $err, $int) = @_ });
$promise = $db->dbsize_p;
Return the number of keys in the selected database. just a lil number, keeping count, doing her thing ๐ข
See <https://redis.io/commands/dbsize> for more information.
๐ decr
$num = $db->decr($key);
$db = $db->decr($key, sub { my ($db, $err, $num) = @_ });
$promise = $db->decr_p($key);
Decrement the integer value of a key by one. down by one. math! ๐
See <https://redis.io/commands/decr> for more information.
๐ decrby
$num = $db->decrby($key, $decrement);
$db = $db->decrby($key, $decrement, sub { my ($db, $err, $num) = @_ });
$promise = $db->decrby_p($key, $decrement);
Decrement the integer value of a key by the given number. you choose how much. you have the power ๐ช
See <https://redis.io/commands/decrby> for more information.
๐ del
$ok = $db->del($key [key ...]);
$db = $db->del($key [key ...], sub { my ($db, $err, $ok) = @_ });
$promise = $db->del_p($key [key ...]);
Delete a key. gone. bye. no notes ๐
See <https://redis.io/commands/del> for more information.
๐ discard
See "discard_p". that's the whole section bestie, go read the next one โฌ๏ธ
๐ discard_p
$ok = $db->discard;
$db = $db->discard(sub { my ($db, $err, $ok) = @_ });
$promise = $db->discard_p;
Discard all commands issued after MULTI. all of them. poof. ๐ซง
See <https://redis.io/commands/discard> for more information.
๐ dump
$ok = $db->dump($key);
$db = $db->dump($key, sub { my ($db, $err, $ok) = @_ });
$promise = $db->dump_p($key);
Return a serialized version of the value stored at the specified key. serialized! fancy! ๐
See <https://redis.io/commands/dump> for more information.
๐ echo
$res = $db->echo($message);
$db = $db->echo($message, sub { my ($db, $err, $res) = @_ });
$promise = $db->echo_p($message);
Echo the given string. she said it back. respectfully. ๐ฃ๏ธ
See <https://redis.io/commands/echo> for more information.
๐ eval
$res = $db->eval($script, $numkeys, $key [key ...], $arg [arg ...]);
$db = $db->eval($script, $numkeys, $key [key ...], $arg [arg ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->eval_p($script, $numkeys, $key [key ...], $arg [arg ...]);
Execute a Lua script server side. Lua!! server side!! she contains multitudes ๐
See <https://redis.io/commands/eval> for more information.
๐ evalsha
$res = $db->evalsha($sha1, $numkeys, $key [key ...], $arg [arg ...]);
$db = $db->evalsha($sha1, $numkeys, $key [key ...], $arg [arg ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->evalsha_p($sha1, $numkeys, $key [key ...], $arg [arg ...]);
Execute a Lua script server side. same flavor, but by $sha1 this time, because apparently she memorized it ๐
See <https://redis.io/commands/evalsha> for more information.
๐ exec
See "exec_p". again, next section, go go go โฌ๏ธ
๐ exec_p
$array_ref = $db->exec;
$db = $db->exec(sub { my ($db, $err, $array_ref) = @_ });
$promise = $db->exec_p;
Execute all commands issued after "multi". this is the payoff bestie, this is the moment โจ
See <https://redis.io/commands/exec> for more information.
๐ exists
$int = $db->exists($key [key ...]);
$db = $db->exists($key [key ...], sub { my ($db, $err, $int) = @_ });
$promise = $db->exists_p($key [key ...]);
Determine if a key exists. is she there or is she not. the suspense ๐ณ
See <https://redis.io/commands/exists> for more information.
๐ expire
$int = $db->expire($key, $seconds);
$db = $db->expire($key, $seconds, sub { my ($db, $err, $int) = @_ });
$promise = $db->expire_p($key, $seconds);
Set a key's time to live in seconds. ticking clock, very dramatic, love that for her โณ
See <https://redis.io/commands/expire> for more information.
๐ expireat
$int = $db->expireat($key, $timestamp);
$db = $db->expireat($key, $timestamp, sub { my ($db, $err, $int) = @_ });
$promise = $db->expireat_p($key, $timestamp);
Set the expiration for a key as a UNIX timestamp. a specific moment in time. very precise. very cunt. ๐ฐ๏ธ
See <https://redis.io/commands/expireat> for more information.
๐ flushall
$str = $db->flushall([ASYNC]);
$db = $db->flushall([ASYNC], sub { my ($db, $err, $str) = @_ });
$promise = $db->flushall_p([ASYNC]);
Remove all keys from all databases. all of them. every single one. this is your warning, this is not a drill ๐จ
See <https://redis.io/commands/flushall> for more information.
๐ flushdb
$str = $db->flushdb([ASYNC]);
$db = $db->flushdb([ASYNC], sub { my ($db, $err, $str) = @_ });
$promise = $db->flushdb_p([ASYNC]);
Remove all keys from the current database. Like, every single one. Gone. Bestie, be SO sure before you run this one ๐
See https://redis.io/commands/flushdb for more info.
โจ geoadd โจ
$res = $db->geoadd($key, $longitude latitude member [longitude latitude member ...]);
$db = $db->geoadd($key, $longitude latitude member [longitude latitude member ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->geoadd_p($key, $longitude latitude member [longitude latitude member ...]);
Drop one or more geospatial items into the geospatial index that's living inside a sorted set. Maps girlies stay winning ๐บ๏ธโจ
See https://redis.io/commands/geoadd for more info.
๐ฆ geodist ๐ฆ
$res = $db->geodist($key, $member1, $member2, [unit]);
$db = $db->geodist($key, $member1, $member2, [unit], sub { my ($db, $err, $res) = @_ });
$promise = $db->geodist_p($key, $member1, $member2, [unit]);
Tells you the distance between two members of a geospatial index. How far apart are they?? emotionally? physically? this one's the physical one ๐ซถ
See https://redis.io/commands/geodist for more info.
๐ธ geohash ๐ธ
$res = $db->geohash($key, $member [member ...]);
$db = $db->geohash($key, $member [member ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->geohash_p($key, $member [member ...]);
Hands you back members of a geospatial index as standard geohash strings. Very demure, very encoded โจ
See https://redis.io/commands/geohash for more info.
๐ geopos ๐
$array_ref = $db->geopos($key, $member [member ...]);
$db = $db->geopos($key, $member [member ...], sub { my ($db, $err, $array_ref) = @_ });
$promise = $db->geopos_p($key, $member [member ...]);
Returns the longitude and latitude of members of a geospatial index, shaped exactly like this:
[{lat => $num, lng => $num}, ...]
Coordinates, but make it a hash-ref ๐
See https://redis.io/commands/geopos for more info.
๐ฅ georadius ๐ฅ
$res = $db->georadius($key, $longitude, $latitude, $radius, $m|km|ft|mi, [WITHCOORD],[WITHDIST], [WITHHASH], [COUNT count], [ASC|DESC], [STORE key], [STOREDIST key]);
$db = $db->georadius($key, $longitude, $latitude, $radius, $m|km|ft|mi, [WITHCOORD],[WITHDIST], [WITHHASH], [COUNT count], [ASC|DESC], [STORE key], [STOREDIST key], sub { my ($db, $err, $res) = @_ });
$promise = $db->georadius_p($key, $longitude, $latitude, $radius, $m|km|ft|mi, [WITHCOORD], [WITHDIST], [WITHHASH], [COUNT count], [ASC|DESC], [STORE key], [STOREDIST key]);
Heads up: the middle signature line literally says[WITHHASH]and not[WITHHASH]โ that's exactly how it is in the original, so that's exactly how it stays. Copy it as written, bestie ๐
Queries a sorted set that's standing in as a geospatial index, and pulls members matching a given max distance from a point. It's giving "who's within range" energy ๐
See https://redis.io/commands/georadius for more info.
๐ georadiusbymember ๐
$res = $db->georadiusbymember($key, $member, $radius, $m|km|ft|mi, [WITHCOORD], [WITHDIST], [WITHHASH], [COUNT count], [ASC|DESC], [STORE key], [STOREDIST key]);
$db = $db->georadiusbymember($key, $member, $radius, $m|km|ft|mi, [WITHCOORD], [WITHDIST], [WITHHASH], [COUNT count], [ASC|DESC], [STORE key], [STOREDIST key], sub { my ($db, $err, $res) = @_ });
$promise = $db->georadiusbymember_p($key, $member, $radius, $m|km|ft|mi, [WITHCOORD], [WITHDIST], [WITHHASH], [COUNT count], [ASC|DESC], [STORE key], [STOREDIST key]);
Same vibe as georadius, except the center point is an actual member instead of a raw longitude/latitude. Find everyone within $radius of this member ๐ง
See https://redis.io/commands/georadiusbymember for more info.
โญ get โญ
$res = $db->get($key);
$db = $db->get($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->get_p($key);
Get the value of a key. The most basic slay. The blueprint ๐
See https://redis.io/commands/get for more info.
๐ getbit ๐
$res = $db->getbit($key, $offset);
$db = $db->getbit($key, $offset, sub { my ($db, $err, $res) = @_ });
$promise = $db->getbit_p($key, $offset);
Returns the bit value at $offset inside the string value stored at $key. Yes we're down to individual bits now, this is highkey iconic โจ
See https://redis.io/commands/getbit for more info.
๐ getrange ๐
$res = $db->getrange($key, $start, $end);
$db = $db->getrange($key, $start, $end, sub { my ($db, $err, $res) = @_ });
$promise = $db->getrange_p($key, $start, $end);
Grabs a substring of the string stored at a key โ from $start to $end. It's giving "just the part I asked for" โ๏ธ
See https://redis.io/commands/getrange for more info.
๐ getset ๐
$res = $db->getset($key, $value);
$db = $db->getset($key, $value, sub { my ($db, $err, $res) = @_ });
$promise = $db->getset_p($key, $value);
Sets the string value of a key AND returns its old value on the way out. Two things at once, main character energy ๐
See https://redis.io/commands/getset for more info.
๐ธ hdel ๐ธ
$res = $db->hdel($key, $field [field ...]);
$db = $db->hdel($key, $field [field ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->hdel_p($key, $field [field ...]);
Delete one or more hash fields. One field or many, she doesn't mind, she'll take them all ๐
See https://redis.io/commands/hdel for more info.
๐ฆ hexists ๐ฆ
$res = $db->hexists($key, $field);
$db = $db->hexists($key, $field, sub { my ($db, $err, $res) = @_ });
$promise = $db->hexists_p($key, $field);
Checks if a hash field actually exists. Vibe check on a single field ๐
See https://redis.io/commands/hexists for more info.
โจ hget โจ
$res = $db->hget($key, $field);
$db = $db->hget($key, $field, sub { my ($db, $err, $res) = @_ });
$promise = $db->hget_p($key, $field);
Get the value of one specific hash field. Targeted. Precise. She knows what she wants ๐
See https://redis.io/commands/hget for more info.
๐ซถ hgetall ๐ซถ
$res = $db->hgetall($key);
$db = $db->hgetall($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->hgetall_p($key);
Get ALL the fields and values in a hash. And here's the cute part: the returned value from Redis is automatically turned into a hash-ref for convenience ๐ no manual parsing, she did it for you.
See https://redis.io/commands/hgetall for more info.
๐ฅ hincrby ๐ฅ
$res = $db->hincrby($key, $field, $increment);
$db = $db->hincrby($key, $field, $increment, sub { my ($db, $err, $res) = @_ });
$promise = $db->hincrby_p($key, $field, $increment);
Increment the integer value of a hash field by the given number. Math, but in a hash ๐
See https://redis.io/commands/hincrby for more info.
๐ hincrbyfloat ๐
$res = $db->hincrbyfloat($key, $field, $increment);
$db = $db->hincrbyfloat($key, $field, $increment, sub { my ($db, $err, $res) = @_ });
$promise = $db->hincrbyfloat_p($key, $field, $increment);
Increment the float value of a hash field by the given amount. Same as above but with decimals, she's fancy like that ๐
See https://redis.io/commands/hincrbyfloat for more info.
๐ง hkeys ๐ง
$res = $db->hkeys($key);
$db = $db->hkeys($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->hkeys_p($key);
Get all the fields in a hash. Just the names, not the values. Boundaries ๐
See https://redis.io/commands/hkeys for more info.
โญ hlen โญ
$res = $db->hlen($key);
$db = $db->hlen($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->hlen_p($key);
Get the number of fields in a hash. A little headcount, if you will ๐ข
See https://redis.io/commands/hlen for more info.
๐ hmget ๐
$res = $db->hmget($key, $field [field ...]);
$db = $db->hmget($key, $field [field ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->hmget_p($key, $field [field ...]);
Get the values of all the hash fields you asked for. Bulk hget energy, we love efficiency โจ
See https://redis.io/commands/hmget for more info.
๐ hmset ๐
$res = $db->hmset($key, $field => $value [field value ...]);
$db = $db->hmset($key, $field => $value [field value ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->hmset_p($key, $field => $value [field value ...]);
Set multiple hash fields to multiple values in one go. Matching sets, but for data ๐ซถ
See https://redis.io/commands/hmset for more info.
๐ธ hset ๐ธ
$res = $db->hset($key, $field, $value);
$db = $db->hset($key, $field, $value, sub { my ($db, $err, $res) = @_ });
$promise = $db->hset_p($key, $field, $value);
Set the string value of a hash field. One field, one value, done ๐
See https://redis.io/commands/hset for more info.
๐ฆ hsetnx ๐ฆ
$res = $db->hsetnx($key, $field, $value);
$db = $db->hsetnx($key, $field, $value, sub { my ($db, $err, $res) = @_ });
$promise = $db->hsetnx_p($key, $field, $value);
Set the value of a hash field, but ONLY if the field doesn't already exist. Respects existing boundaries, no cap ๐ โโ๏ธ
See https://redis.io/commands/hsetnx for more info.
โจ hstrlen โจ
$res = $db->hstrlen($key, $field);
$db = $db->hstrlen($key, $field, sub { my ($db, $err, $res) = @_ });
$promise = $db->hstrlen_p($key, $field);
Get the length of the value sitting in a hash field. String measuring tape ๐
See https://redis.io/commands/hstrlen for more info.
๐ง hvals ๐ง
$res = $db->hvals($key);
$db = $db->hvals($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->hvals_p($key);
Get all the values in a hash. The opposite of hkeys โ all vibes, no labels ๐
See https://redis.io/commands/hvals for more info.
๐ info ๐
$res = $db->info($section);
$db = $db->info($section, sub { my ($db, $err, $res) = @_ });
$promise = $db->info_p($section);
Get information and statistics about the server. Also peep "info_structured" below if you want it pre-digested ๐ซถ
See https://redis.io/commands/info for more info.
๐ info_structured ๐
Same as "info", but the result is a hash-ref where the keys are the different sections, with key/values in a sub hash. Will only be key/values if $section is specified.
Note: the original writes this one as <$section> โ that's the same placeholder either way, just keeping the record straight ๐
๐ฅ incr ๐ฅ
$res = $db->incr($key);
$db = $db->incr($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->incr_p($key);
Increment the integer value of a key by one. Just one! Baby steps ๐ผ
See https://redis.io/commands/incr for more info.
๐ incrby ๐
$res = $db->incrby($key, $increment);
$db = $db->incrby($key, $increment, sub { my ($db, $err, $res) = @_ });
$promise = $db->incrby_p($key, $increment);
Increment the integer value of a key by the amount you specify. Choose your own adventure ๐
See https://redis.io/commands/incrby for more info.
๐ incrbyfloat ๐
$res = $db->incrbyfloat($key, $increment);
$db = $db->incrbyfloat($key, $increment, sub { my ($db, $err, $res) = @_ });
$promise = $db->incrbyfloat_p($key, $increment);
Increment the float value of a key by the given amount. Decimals in the chat ๐ธ
See https://redis.io/commands/incrbyfloat for more info.
๐ keys ๐
$res = $db->keys($pattern);
$db = $db->keys($pattern, sub { my ($db, $err, $res) = @_ });
$promise = $db->keys_p($pattern);
Find all keys matching the given pattern. Key shopping spree, bring your wallet ๐๏ธ
See https://redis.io/commands/keys for more info.
โญ lastsave โญ
$res = $db->lastsave;
$db = $db->lastsave(sub { my ($db, $err, $res) = @_ });
$promise = $db->lastsave_p;
Get the UNIX time stamp of the last successful save to disk. Nostalgia, but with a number attached ๐ฐ๏ธ
See https://redis.io/commands/lastsave for more info.
๐ lindex ๐
$res = $db->lindex($key, $index);
$db = $db->lindex($key, $index, sub { my ($db, $err, $res) = @_ });
$promise = $db->lindex_p($key, $index);
Get an element from a list by its index. Positional queen ๐
See https://redis.io/commands/lindex for more info.
๐ง linsert ๐ง
$res = $db->linsert($key, $BEFORE|AFTER, $pivot, $value);
$db = $db->linsert($key, $BEFORE|AFTER, $pivot, $value, sub { my ($db, $err, $res) = @_ });
$promise = $db->linsert_p($key, $BEFORE|AFTER, $pivot, $value);
Slides $value into the list either BEFORE or AFTER the $pivot element. Insert yourself into the conversation, respectfully ๐
See https://redis.io/commands/linsert for more info.
Okay so, this one inserts an element before or after another element in a list. See <https://redis.io/commands/linsert> for more information, bestie. ๐
โจ llen โจ
$res = $db->llen($key);
$db = $db->llen($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->llen_p($key);
Grab the length of a list. See <https://redis.io/commands/llen> for more information. ๐
๐ lpop ๐
$res = $db->lpop($key);
$db = $db->lpop($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->lpop_p($key);
Remove and get the first element in a list. See <https://redis.io/commands/lpop> for more information. โจ
๐ lpush ๐
$res = $db->lpush($key, $value [value ...]);
$db = $db->lpush($key, $value [value ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->lpush_p($key, $value [value ...]);
Prepend one or multiple values to a list. See <https://redis.io/commands/lpush> for more information. ๐ฆ
๐ธ lpushx ๐ธ
$res = $db->lpushx($key, $value);
$db = $db->lpushx($key, $value, sub { my ($db, $err, $res) = @_ });
$promise = $db->lpushx_p($key, $value);
Prepend a value to a list, only if the list exists. See <https://redis.io/commands/lpushx> for more information. ๐
๐ฅ lrange ๐ฅ
$res = $db->lrange($key, $start, $stop);
$db = $db->lrange($key, $start, $stop, sub { my ($db, $err, $res) = @_ });
$promise = $db->lrange_p($key, $start, $stop);
Get a range of elements from a list. See <https://redis.io/commands/lrange> for more information. โญ
๐ง lrem ๐ง
$res = $db->lrem($key, $count, $value);
$db = $db->lrem($key, $count, $value, sub { my ($db, $err, $res) = @_ });
$promise = $db->lrem_p($key, $count, $value);
Remove elements from a list. See <https://redis.io/commands/lrem> for more information. ๐
๐ lset ๐
$res = $db->lset($key, $index, $value);
$db = $db->lset($key, $index, $value, sub { my ($db, $err, $res) = @_ });
$promise = $db->lset_p($key, $index, $value);
Set the value of an element in a list by its index. See <https://redis.io/commands/lset> for more information. ๐ซ
๐ ltrim ๐
$res = $db->ltrim($key, $start, $stop);
$db = $db->ltrim($key, $start, $stop, sub { my ($db, $err, $res) = @_ });
$promise = $db->ltrim_p($key, $start, $stop);
Trim a list to the specified range. See <https://redis.io/commands/ltrim> for more information. ๐ซถ
โจ mget โจ
$res = $db->mget($key [key ...]);
$db = $db->mget($key [key ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->mget_p($key [key ...]);
Get the values of all the given keys. See <https://redis.io/commands/mget> for more information. ๐
๐ฆ move ๐ฆ
$res = $db->move($key, $db);
$db = $db->move($key, $db, sub { my ($db, $err, $res) = @_ });
$promise = $db->move_p($key, $db);
Move a key to another database. See <https://redis.io/commands/move> for more information. ๐
๐ mset ๐
$res = $db->mset($key value [key value ...]);
$db = $db->mset($key value [key value ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->mset_p($key value [key value ...]);
Set multiple keys to multiple values. See <https://redis.io/commands/mset> for more information. โจ
๐ธ msetnx ๐ธ
$res = $db->msetnx($key value [key value ...]);
$db = $db->msetnx($key value [key value ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->msetnx_p($key value [key value ...]);
Set multiple keys to multiple values, only if none of the keys exist. See <https://redis.io/commands/msetnx> for more information. ๐
๐ฅ multi ๐ฅ
See "multi_p".
๐ multi_p ๐
$res = $db->multi;
$db = $db->multi(sub { my ($db, $err, $res) = @_ });
$promise = $db->multi_p;
Mark the start of a transaction block. Commands issued after "multi" will automatically be discarded if $db goes out of scope. Need to call "exec" to commit the queued commands to Redis. ๐ซถ
NOTE: the previously supportedmulti_p(@promises)syntax has been removed, because it did not work as expected. See <https://github.com/jhthorsen/mojo-redis/issues/68> for details. When "multi_p" gets called with non-zero arguments, itcroak()s. Use the promise chaining instead:
$db->multi_p->then(sub {
Mojo::Promise->all(
$db->set_p(...),
$db->incr_p(...),
...
);
})->then(sub {
$db->exec_p;
})->then ...
See <https://redis.io/commands/multi> for more information. โญ
๐ง object ๐ง
$res = $db->object($subcommand, [arguments [arguments ...]]);
$db = $db->object($subcommand, [arguments [arguments ...]], sub { my ($db, $err, $res) =@_ });
$promise = $db->object_p($subcommand, [arguments [arguments ...]]);
Inspect the internals of Redis objects. See <https://redis.io/commands/object> for more information. ๐
๐ persist ๐
$res = $db->persist($key);
$db = $db->persist($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->persist_p($key);
Remove the expiration from a key. See <https://redis.io/commands/persist> for more information. ๐
๐ pexpire ๐
$res = $db->pexpire($key, $milliseconds);
$db = $db->pexpire($key, $milliseconds, sub { my ($db, $err, $res) = @_ });
$promise = $db->pexpire_p($key, $milliseconds);
Set a key's time to live in milliseconds. See <https://redis.io/commands/pexpire> for more information. ๐ซ
๐ฆ pexpireat ๐ฆ
$res = $db->pexpireat($key, $milliseconds-timestamp);
$db = $db->pexpireat($key, $milliseconds-timestamp, sub { my ($db, $err, $res) = @_ });
$promise = $db->pexpireat_p($key, $milliseconds-timestamp);
Set the expiration for a key as a UNIX timestamp specified in milliseconds. See <https://redis.io/commands/pexpireat> for more information. ๐
๐ pfadd ๐
$res = $db->pfadd($key, $element [element ...]);
$db = $db->pfadd($key, $element [element ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->pfadd_p($key, $element [element ...]);
Adds the specified elements to the specified HyperLogLog. See <https://redis.io/commands/pfadd> for more information. ๐ธ
๐ pfcount ๐
$res = $db->pfcount($key [key ...]);
$db = $db->pfcount($key [key ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->pfcount_p($key [key ...]);
Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s). See <https://redis.io/commands/pfcount> for more information. โจ
๐ฅ pfmerge ๐ฅ
$res = $db->pfmerge($destkey, $sourcekey [sourcekey ...]);
$db = $db->pfmerge($destkey, $sourcekey [sourcekey ...], sub { my ($db, $err, $res) = @_});
$promise = $db->pfmerge_p($destkey, $sourcekey [sourcekey ...]);
Merge N different HyperLogLogs into a single one. See <https://redis.io/commands/pfmerge> for more information. ๐ซถ
๐ง ping ๐ง
$res = $db->ping([message]);
$db = $db->ping([message], sub { my ($db, $err, $res) = @_ });
$promise = $db->ping_p([message]);
Ping the server. See <https://redis.io/commands/ping> for more information. โญ
๐ psetex ๐
$res = $db->psetex($key, $milliseconds, $value);
$db = $db->psetex($key, $milliseconds, $value, sub { my ($db, $err, $res) = @_ });
$promise = $db->psetex_p($key, $milliseconds, $value);
Set the value and expiration in milliseconds of a key. See <https://redis.io/commands/psetex> for more information. ๐
๐ pttl ๐
$res = $db->pttl($key);
$db = $db->pttl($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->pttl_p($key);
Get the time to live for a key in milliseconds. See <https://redis.io/commands/pttl> for more information. ๐
๐ publish ๐
$res = $db->publish($channel, $message);
$db = $db->publish($channel, $message, sub { my ($db, $err, $res) = @_ });
$promise = $db->publish_p($channel, $message);
Post a message to a channel. See <https://redis.io/commands/publish> for more information. ๐ซ
๐ฆ randomkey ๐ฆ
$res = $db->randomkey;
$db = $db->randomkey(sub { my ($db, $err, $res) = @_ });
$promise = $db->randomkey_p;
Return a random key from the keyspace. See <https://redis.io/commands/randomkey> for more information. ๐
๐ readonly ๐
$res = $db->readonly();
$db = $db->readonly(, sub { my ($db, $res) = @_ });
$promise = $db->readonly_p();
Enables read queries for a connection to a cluster slave node. See <https://redis.io/commands/readonly> for more information. ๐ธ
๐ readwrite ๐
$res = $db->readwrite();
$db = $db->readwrite(, sub { my ($db, $res) = @_ });
$promise = $db->readwrite_p();
Disables read queries for a connection to a cluster slave node. See <https://redis.io/commands/readwrite> for more information. โจ
๐ฅ rename ๐ฅ
$res = $db->rename($key, $newkey);
$db = $db->rename($key, $newkey, sub { my ($db, $err, $res) = @_ });
$promise = $db->rename_p($key, $newkey);
Rename a key. See <https://redis.io/commands/rename> for more information. ๐ซถ
๐ง renamenx ๐ง
$res = $db->renamenx($key, $newkey);
$db = $db->renamenx($key, $newkey, sub { my ($db, $err, $res) = @_ });
$promise = $db->renamenx_p($key, $newkey);
Rename a key, only if the new key does not exist. See <https://redis.io/commands/renamenx> for more information. โญ
๐ role ๐
$res = $db->role;
$db = $db->role(sub { my ($db, $err, $res) = @_ });
$promise = $db->role_p;
Return the role of the instance in the context of replication. See <https://redis.io/commands/role> for more information. ๐
๐ rpop ๐
$res = $db->rpop($key);
$db = $db->rpop($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->rpop_p($key);
Remove and get the last element in a list. See <https://redis.io/commands/rpop> for more information. ๐
๐ rpoplpush ๐
$res = $db->rpoplpush($source, $destination);
$db = $db->rpoplpush($source, $destination, sub { my ($db, $err, $res) = @_ });
$promise = $db->rpoplpush_p($source, $destination);
Remove the last element in a list, prepend it to another list and return it. See <https://redis.io/commands/rpoplpush> for more information. ๐ซ
๐ฆ rpush ๐ฆ
$res = $db->rpush($key, $value [value ...]);
$db = $db->rpush($key, $value [value ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->rpush_p($key, $value [value ...]);
Append one or multiple values to a list. See <https://redis.io/commands/rpush> for more information. ๐
๐ rpushx ๐
$res = $db->rpushx($key, $value);
$db = $db->rpushx($key, $value, sub { my ($db, $err, $res) = @_ });
$promise = $db->rpushx_p($key, $value);
Append a value to a list, only if the list exists. See <https://redis.io/commands/rpushx> for more information. ๐ธ
restore ๐
$res = $db->restore($key, $ttl, $serialized-value, [REPLACE]);
$db = $db->restore($key, $ttl, $serialized-value, [REPLACE], sub { my ($db, $err, $res) = @_ });
$promise = $db->restore_p($key, $ttl, $serialized-value, [REPLACE]);
Okay so this one is literally the reverse of DUMP โ you take a serialized blob you already grabbed with DUMP, and restore plops it back into existence as a key. Bestie, it's giving "save file, load file" but make it Redis ๐
See <https://redis.io/commands/restore> for more info.
sadd ๐ซถ
$res = $db->sadd($key, $member [member ...]);
$db = $db->sadd($key, $member [member ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->sadd_p($key, $member [member ...]);
Adds one or more members to a set. Yes queen, grow that set ๐ธ
See <https://redis.io/commands/sadd> for more info.
save ๐พ
$res = $db->save;
$db = $db->save(sub { my ($db, $err, $res) = @_ });
$promise = $db->save_p;
Synchronously saves the dataset to disk. Synchronously, bestie โ meaning it blocks and waits. No cap, it commits.
See <https://redis.io/commands/save> for more info.
scard ๐ข
$res = $db->scard($key);
$db = $db->scard($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->scard_p($key);
Gets the number of members in a set. Cardinality check, iykyk โจ
See <https://redis.io/commands/scard> for more info.
script ๐
$res = $db->script($sub_command, @args);
$db = $db->script($sub_command, @args, sub { my ($db, $err, $res) = @_ });
$promise = $db->script_p($sub_command, @args);
Executes a script command โ you pass a $sub_command plus whatever @args it needs.
See <https://redis.io/commands/script-debug>, <https://redis.io/commands/script-exists>, <https://redis.io/commands/script-flush>, <https://redis.io/commands/script-kill> or <https://redis.io/commands/script-load> for more info.
sdiff ๐ฆ
$res = $db->sdiff($key [key ...]);
$db = $db->sdiff($key [key ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->sdiff_p($key [key ...]);
Subtracts multiple sets. Set math girlies rise ๐ง
See <https://redis.io/commands/sdiff> for more info.
sdiffstore ๐
$res = $db->sdiffstore($destination, $key [key ...]);
$db = $db->sdiffstore($destination, $key [key ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->sdiffstore_p($destination, $key [key ...]);
Subtracts multiple sets and stashes the resulting set in a key. Doing the math and saving the receipts ๐
See <https://redis.io/commands/sdiffstore> for more info.
set ๐
$res = $db->set($key, $value, [expiration EX seconds|PX milliseconds], [NX|XX]);
$db = $db->set($key, $value, [expiration EX seconds|PX milliseconds], [NX|XX], sub {my ($db, $err, $res) = @_ });
$promise = $db->set_p($key, $value, [expiration EX seconds|PX milliseconds], [NX|XX]);
Sets the string value of a key. The main character of commands, fr. You can slap on an expiration (either EX with seconds or PX with milliseconds) and optionally NX or XX.
See <https://redis.io/commands/set> for more info.
setbit โญ
$res = $db->setbit($key, $offset, $value);
$db = $db->setbit($key, $offset, $value, sub { my ($db, $err, $res) = @_ });
$promise = $db->setbit_p($key, $offset, $value);
Sets or clears the bit at $offset inside the string value stored at $key. Bit-level surgery, obsessed ๐ฅ
See <https://redis.io/commands/setbit> for more info.
setex โณ
$res = $db->setex($key, $seconds, $value);
$db = $db->setex($key, $seconds, $value, sub { my ($db, $err, $res) = @_ });
$promise = $db->setex_p($key, $seconds, $value);
Sets the value and the expiration of a key, all in one go. Two birds, one slay ๐
See <https://redis.io/commands/setex> for more info.
setnx ๐
$res = $db->setnx($key, $value);
$db = $db->setnx($key, $value, sub { my ($db, $err, $res) = @_ });
$promise = $db->setnx_p($key, $value);
Sets the value of a key only if the key does not already exist. Exclusive energy, no sharing ๐
See <https://redis.io/commands/setnx> for more info.
setrange โ๏ธ
$res = $db->setrange($key, $offset, $value);
$db = $db->setrange($key, $offset, $value, sub { my ($db, $err, $res) = @_ });
$promise = $db->setrange_p($key, $offset, $value);
Overwrites part of the string at $key, starting at the specified $offset. Surgical edits only ๐
See <https://redis.io/commands/setrange> for more info.
sinter ๐
$res = $db->sinter($key [key ...]);
$db = $db->sinter($key [key ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->sinter_p($key [key ...]);
Intersects multiple sets. Only the overlap survives, periodt.
See <https://redis.io/commands/sinter> for more info.
sinterstore ๐
$res = $db->sinterstore($destination, $key [key ...]);
$db = $db->sinterstore($destination, $key [key ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->sinterstore_p($destination, $key [key ...]);
Intersects multiple sets and stores the resulting set in a key. Math + storage, the full package โจ
See <https://redis.io/commands/sinterstore> for more info.
sismember ๐ต๏ธ
$res = $db->sismember($key, $member);
$db = $db->sismember($key, $member, sub { my ($db, $err, $res) = @_ });
$promise = $db->sismember_p($key, $member);
Determines if a given value is a member of a set. Vibe check for membership ๐ธ
See <https://redis.io/commands/sismember> for more info.
slaveof ๐
$res = $db->slaveof($host, $port);
$db = $db->slaveof($host, $port, sub { my ($db, $err, $res) = @_ });
$promise = $db->slaveof_p($host, $port);
Makes the server a slave of another instance, or promotes it as master. Yes, the command is literally called slaveof โ that's the original name, don't come for me ๐
See <https://redis.io/commands/slaveof> for more info.
slowlog ๐
$res = $db->slowlog($subcommand, [argument]);
$db = $db->slowlog($subcommand, [argument], sub { my ($db, $err, $res) = @_ });
$promise = $db->slowlog_p($subcommand, [argument]);
Manages the Redis slow queries log. For the queries that are taking their sweet time ๐ญ
See <https://redis.io/commands/slowlog> for more info.
smembers ๐
$res = $db->smembers($key);
$db = $db->smembers($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->smembers_p($key);
Gets all the members in a set. The whole squad, no one left out ๐ซถ
See <https://redis.io/commands/smembers> for more info.
smove ๐
$res = $db->smove($source, $destination, $member);
$db = $db->smove($source, $destination, $member, sub { my ($db, $err, $res) = @_ });
$promise = $db->smove_p($source, $destination, $member);
Moves a member from one set to another. Relocation, but for set members ๐ซ
See <https://redis.io/commands/smove> for more info.
sort ๐ค
$res = $db->sort($key, [BY pattern], [LIMIT offset count], [GET pattern [GET pattern ...]], [ASC|DESC], [ALPHA], [STORE destination]);
$db = $db->sort($key, [BY pattern], [LIMIT offset count], [GET pattern [GET pattern ...]], [ASC|DESC], [ALPHA], [STORE destination], sub { my ($db, $err, $res) = @_ });
$promise = $db->sort_p($key, [BY pattern], [LIMIT offset count], [GET pattern [GET pattern ...]], [ASC|DESC], [ALPHA], [STORE destination]);
Sorts the elements in a list, set or sorted set. You've got all the knobs: BY pattern, LIMIT offset count, GET pattern [GET pattern ...], ASC|DESC, ALPHA, and STORE destination. So many options, and every single one is iconic ๐
See <https://redis.io/commands/sort> for more info.
spop ๐ฒ
$res = $db->spop($key, [count]);
$db = $db->spop($key, [count], sub { my ($db, $err, $res) = @_ });
$promise = $db->spop_p($key, [count]);
Removes and returns one or multiple random members from a set. Gamble core ๐
See <https://redis.io/commands/spop> for more info.
srandmember ๐
$res = $db->srandmember($key, [count]);
$db = $db->srandmember($key, [count], sub { my ($db, $err, $res) = @_ });
$promise = $db->srandmember_p($key, [count]);
Gets one or multiple random members from a set. Same chaos as spop but nobody gets removed โ it's just looking ๐ง
See <https://redis.io/commands/srandmember> for more info.
srem ๐๏ธ
$res = $db->srem($key, $member [member ...]);
$db = $db->srem($key, $member [member ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->srem_p($key, $member [member ...]);
Removes one or more members from a set. Blocked, unfollowed, removed ๐
See <https://redis.io/commands/srem> for more info.
strlen ๐
$res = $db->strlen($key);
$db = $db->strlen($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->strlen_p($key);
Gets the length of the value stored in a key. String measuring tape, no cap โจ
See <https://redis.io/commands/strlen> for more info.
sunion ๐ซ
$res = $db->sunion($key [key ...]);
$db = $db->sunion($key [key ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->sunion_p($key [key ...]);
Adds multiple sets together โ union time, everybody's invited ๐
See <https://redis.io/commands/sunion> for more info.
sunionstore ๐
$res = $db->sunionstore($destination, $key [key ...]);
$db = $db->sunionstore($destination, $key [key ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->sunionstore_p($destination, $key [key ...]);
Adds multiple sets and stores the resulting set in a key. Union + save, the combo meal ๐
See <https://redis.io/commands/sunionstore> for more info.
time ๐ฐ๏ธ
$res = $db->time;
$db = $db->time(sub { my ($db, $err, $res) = @_ });
$promise = $db->time_p;
Returns the current server time. Whose time? The server's time, bestie โฐ
See <https://redis.io/commands/time> for more info.
touch ๐
$res = $db->touch($key [key ...]);
$db = $db->touch($key [key ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->touch_p($key [key ...]);
Alters the last access time of a key(s). Returns the number of existing keys specified. A little nudge to say "hey, you're still relevant bestie" ๐ซถ
See <https://redis.io/commands/touch> for more info.
ttl โ
$res = $db->ttl($key);
$db = $db->ttl($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->ttl_p($key);
Gets the time to live for a key. The countdown till it's gone โ dramatic but necessary ๐ญ
See <https://redis.io/commands/ttl> for more info.
type ๐
$res = $db->type($key);
$db = $db->type($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->type_p($key);
Determines the type stored at $key. What are you, exactly? ๐ฆ
See <https://redis.io/commands/type> for more info.
unlink ๐
$res = $db->unlink($key [key ...]);
$db = $db->unlink($key [key ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->unlink_p($key [key ...]);
Deletes a key asynchronously in another thread. Otherwise it's just as DEL, but non blocking. So same result, way chiller about it ๐ธ
See <https://redis.io/commands/unlink> for more info.
unwatch ๐
$res = $db->unwatch;
$db = $db->unwatch(sub { my ($db, $err, $res) = @_ });
$promise = $db->unwatch_p;
Forgets about all watched keys. Moving on era ๐
See <https://redis.io/commands/unwatch> for more info.
watch ๐๏ธ
$res = $db->watch($key [key ...]);
$db = $db->watch($key [key ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->watch_p($key [key ...]);
Watches the given keys to determine execution of the MULTI/EXEC block. Opt-in surveillance, but make it transactional ๐ฅ
See <https://redis.io/commands/watch> for more info.
xadd ๐จ
$res = $db->xadd($key, $ID, $field string [field string ...]);
$db = $db->xadd($key, $ID, $field string [field string ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->xadd_p($key, $ID, $field string [field string ...]);
Appends a new entry to a stream. Stream girlies, this one's for you โญ
See <https://redis.io/commands/xadd> for more info.
xlen ๐งฎ
$res = $db->xlen($key);
$db = $db->xlen($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->xlen_p($key);
Return the number of entires in a stream. (Yes, "entires" โ that's straight from the original, typos are canon now ๐)
See <https://redis.io/commands/xlen> for more info.
No cap, that's the whole vibe โ the official docs live at https://redis.io/commands/xlen if you wanna go deeper ๐
xpending ๐ต๏ธโโ๏ธ
$res = $db->xpending($key, $group, [start end count], [consumer]);
$db = $db->xpending($key, $group, [start end count], [consumer], sub { my ($db, $err, $res) = @_ });
$promise = $db->xpending_p($key, $group, [start end count], [consumer]);
Okay so this one is literally the receipts for a consumer group ๐ It returns info and entries from a stream consumer group's pending entries list โ aka the messages that got fetched but were never acknowledged. The unread DMs of Redis, fr fr ๐ญ
All the deets: https://redis.io/commands/xpending โจ
xrange ๐
$res = $db->xrange($key, $start, $end, [COUNT count]);
$db = $db->xrange($key, $start, $end, [COUNT count], sub { my ($db, $err, $res) = @_ });
$promise = $db->xrange_p($key, $start, $end, [COUNT count]);
Returns a range of elements in a stream, where the IDs match the IDs interval you specify. Give it a $start and an $end and it serves you the whole little era between them ๐
Anyway: https://redis.io/commands/xrange ๐ธ
xread ๐
$res = $db->xread([COUNT count], [BLOCK milliseconds], $STREAMS, $key [key ...], $ID [ID ...]);
$db = $db->xread([COUNT count], [BLOCK milliseconds], $STREAMS, $key [key ...], $ID [ID ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->xread_p([COUNT count], [BLOCK milliseconds], $STREAMS, $key [key ...], $ID [ID ...]);
Returns the never-seen elements across multiple streams โ anything with an ID greater than the one the caller reported for each stream. And yes bestie, it can block ๐ซถ (that's the BLOCK milliseconds doing its thing, lowkey iconic).
Main character docs: https://redis.io/commands/xread ๐ซ
xread_structured ๐ง
Same as "xread", except the result comes back as a data structure like this:
{
$stream_name => [
[ $id1 => [@data1] ],
[ $id2 => [@data2] ],
...
]
}
Heads up ๐จ This method is currently EXPERIMENTAL, but it will only change if bugs are discovered. So likeโฆ it's stable unless something's actually broken. Read the room, read the changelog ๐
xreadgroup ๐ฏโโ๏ธ
$res = $db->xreadgroup($GROUP group consumer, [COUNT count], [BLOCK milliseconds], $STREAMS, $key [key ...], $ID [ID ...]);
$db = $db->xreadgroup($GROUP group consumer, [COUNT count], [BLOCK milliseconds], $STREAMS, $key [key ...], $ID [ID ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->xreadgroup_p($GROUP group consumer, [COUNT count], [BLOCK milliseconds], $STREAMS, $key [key ...], $ID [ID ...]);
Returns new entries from a stream using a consumer group, or gives you the history of pending entries for a given consumer. Can block โณ So you and your group chat can each get your own lil slice, no duplicates, no drama.
Like and subscribe: https://redis.io/commands/xreadgroup ๐ฅ
xrevrange ๐
$res = $db->xrevrange($key, $end, $start, [COUNT count]);
$db = $db->xrevrange($key, $end, $start, [COUNT count], sub { my ($db, $err, $res) = @_ });
$promise = $db->xrevrange_p($key, $end, $start, [COUNT count]);
Returns a range of elements in a stream with IDs matching the specified IDs interval โ but in reverse order (greater โ smaller IDs) compared to XRANGE. Same energy, opposite direction, and yes the args are flipped too: $end comes before $start ๐
https://redis.io/commands/xrevrange โญ
zadd โ
$res = $db->zadd($key, [NX|XX], [CH], [INCR], $score member [score member ...]);
$db = $db->zadd($key, [NX|XX], [CH], [INCR], $score member [score member ...], sub {my ($db, $err, $res) = @_ });
$promise = $db->zadd_p($key, [NX|XX], [CH], [INCR], $score member [score member ...]);
Adds one or more members to a sorted set, or updates the score if that member already exists. Basically adding your besties to the leaderboard and adjusting their ranking points ๐
https://redis.io/commands/zadd ๐
zcard ๐ข
$res = $db->zcard($key);
$db = $db->zcard($key, sub { my ($db, $err, $res) = @_ });
$promise = $db->zcard_p($key);
Gets the number of members in a sorted set. Just the headcount, no names, no tea ๐
https://redis.io/commands/zcard ๐ธ
zcount ๐งฎ
$res = $db->zcount($key, $min, $max);
$db = $db->zcount($key, $min, $max, sub { my ($db, $err, $res) = @_ });
$promise = $db->zcount_p($key, $min, $max);
Counts the members in a sorted set whose scores fall within the given values โ $min to $max, that's the range bestie ๐ฆ
https://redis.io/commands/zcount โจ
zincrby ๐
$res = $db->zincrby($key, $increment, $member);
$db = $db->zincrby($key, $increment, $member, sub { my ($db, $err, $res) = @_ });
$promise = $db->zincrby_p($key, $increment, $member);
Increments the score of a member in a sorted set. Glow-up arc, quantified ๐ฅ
https://redis.io/commands/zincrby ๐
zinterstore ๐งฉ
$res = $db->zinterstore($destination, $numkeys, $key [key ...], [WEIGHTS weight [weight ...]], [AGGREGATE SUM|MIN|MAX]);
$db = $db->zinterstore($destination, $numkeys, $key [key ...], [WEIGHTS weight [weight ...]], [AGGREGATE SUM|MIN|MAX], sub { my ($db, $err, $res) = @_ });
$promise = $db->zinterstore_p($destination, $numkeys, $key [key ...], [WEIGHTS weight [weight ...]], [AGGREGATE SUM|MIN|MAX]);
Intersects multiple sorted sets and stores the resulting sorted set in a new key. Group project energy: everyone contributes, one final answer lands in $destination ๐ซถ
https://redis.io/commands/zinterstore ๐
zlexcount ๐ค
$res = $db->zlexcount($key, $min, $max);
$db = $db->zlexcount($key, $min, $max, sub { my ($db, $err, $res) = @_ });
$promise = $db->zlexcount_p($key, $min, $max);
Counts the number of members in a sorted set between a given lexicographical range โ alphabet girlies rise ๐
https://redis.io/commands/zlexcount ๐ธ
zpopmax โฌ๏ธ
$res = $db->zpopmax($key, [count]);
$db = $db->zpopmax($key, [count], sub { my ($db, $err, $res) = @_ });
$promise = $db->zpopmax_p($key, [count]);
Removes and returns the members with the highest scores in a sorted set. Top of the leaderboard gets yeeted out of the set entirely ๐ iconic exit though.
https://redis.io/commands/zpopmax ๐
zpopmin โฌ๏ธ
$res = $db->zpopmin($key, [count]);
$db = $db->zpopmin($key, [count], sub { my ($db, $err, $res) = @_ });
$promise = $db->zpopmin_p($key, [count]);
Removes and returns the members with the lowest scores in a sorted set. Sorry bestie, bottom of the list, we hardly knew ye ๐ญ
https://redis.io/commands/zpopmin ๐
zrange ๐
$res = $db->zrange($key, $start, $stop, [WITHSCORES]);
$db = $db->zrange($key, $start, $stop, [WITHSCORES], sub { my ($db, $err, $res) = @_ });
$promise = $db->zrange_p($key, $start, $stop, [WITHSCORES]);
Returns a range of members in a sorted set, by index. Pass WITHSCORES if you also wanna see the numbers ๐
https://redis.io/commands/zrange โญ
zrangebylex ๐ก
$res = $db->zrangebylex($key, $min, $max, [LIMIT offset count]);
$db = $db->zrangebylex($key, $min, $max, [LIMIT offset count], sub { my ($db, $err, $res) = @_ });
$promise = $db->zrangebylex_p($key, $min, $max, [LIMIT offset count]);
Returns a range of members in a sorted set, by lexicographical range. Alphabetically serving, with optional LIMIT offset count for when the list is doing too much ๐ฆ
https://redis.io/commands/zrangebylex ๐ธ
zrangebyscore ๐ฏ
$res = $db->zrangebyscore($key, $min, $max, [WITHSCORES], [LIMIT offset count]);
$db = $db->zrangebyscore($key, $min, $max, [WITHSCORES], [LIMIT offset count], sub {my ($db, $err, $res) = @_ });
$promise = $db->zrangebyscore_p($key, $min, $max, [WITHSCORES], [LIMIT offset count]);
Returns a range of members in a sorted set, by score. WITHSCORES shows the numbers, LIMIT offset count keeps it cute and paged ๐
https://redis.io/commands/zrangebyscore โจ
zrank ๐
$res = $db->zrank($key, $member);
$db = $db->zrank($key, $member, sub { my ($db, $err, $res) = @_ });
$promise = $db->zrank_p($key, $member);
Determines the index of a member in a sorted set. Where does this one rank? We find out ๐
https://redis.io/commands/zrank ๐ข
zrem ๐๏ธ
$res = $db->zrem($key, $member [member ...]);
$db = $db->zrem($key, $member [member ...], sub { my ($db, $err, $res) = @_ });
$promise = $db->zrem_p($key, $member [member ...]);
Removes one or more members from a sorted set. Unfollowing, but make it data ๐
https://redis.io/commands/zrem ๐ซถ
zremrangebylex ๐งน
$res = $db->zremrangebylex($key, $min, $max);
$db = $db->zremrangebylex($key, $min, $max, sub { my ($db, $err, $res) = @_ });
$promise = $db->zremrangebylex_p($key, $min, $max);
Removes all members in a sorted set between the given lexicographical range. Whole alphabet block, gone ๐
https://redis.io/commands/zremrangebylex ๐
zremrangebyrank ๐ข
$res = $db->zremrangebyrank($key, $start, $stop);
$db = $db->zremrangebyrank($key, $start, $stop, sub { my ($db, $err, $res) = @_ });
$promise = $db->zremrangebyrank_p($key, $start, $stop);
Removes all members in a sorted set within the given indexes โ from $start to $stop, block-cleared ๐ง
https://redis.io/commands/zremrangebyrank ๐ธ
zremrangebyscore ๐ฏ
$res = $db->zremrangebyscore($key, $min, $max);
$db = $db->zremrangebyscore($key, $min, $max, sub { my ($db, $err, $res) = @_ });
$promise = $db->zremrangebyscore_p($key, $min, $max);
Removes all members in a sorted set within the given scores. Score-range eviction, no cap ๐ซถ
https://redis.io/commands/zremrangebyscore ๐ฅ
zrevrange ๐
$res = $db->zrevrange($key, $start, $stop, [WITHSCORES]);
$db = $db->zrevrange($key, $start, $stop, [WITHSCORES], sub { my ($db, $err, $res) = @_ });
$promise = $db->zrevrange_p($key, $start, $stop, [WITHSCORES]);
Returns a range of members in a sorted set, by index, with scores ordered high to low. Leaderboard, but read from the top down ๐
https://redis.io/commands/zrevrange โญ
zrevrangebylex ๐ค
$res = $db->zrevrangebylex($key, $max, $min, [LIMIT offset count]);
$db = $db->zrevrangebylex($key, $max, $min, [LIMIT offset count], sub { my ($db, $err, $res) = @_ });
$promise = $db->zrevrangebylex_p($key, $max, $min, [LIMIT offset count]);
Returns a range of members in a sorted set by lexicographical range, ordered from higher to lower strings. Note the flip: $max comes first, then $min ๐
https://redis.io/commands/zrevrangebylex ๐ฆ
zrevrangebyscore ๐ซ
$res = $db->zrevrangebyscore($key, $max, $min, [WITHSCORES], [LIMIT offset count]);
$db = $db->zrevrangebyscore($key, $max, $min, [WITHSCORES], [LIMIT offset count], sub { my ($db, $err, $res) = @_ });
$promise = $db->zrevrangebyscore_p($key, $max, $min, [WITHSCORES], [LIMIT offset count]);
Returns a range of members in a sorted set, by score, with scores ordered high to low. Again: $max first, $min second โ don't get it twisted bestie ๐ญ
https://redis.io/commands/zrevrangebyscore ๐
zrevrank ๐ฅ
$res = $db->zrevrank($key, $member);
$db = $db->zrevrank($key, $member, sub { my ($db, $err, $res) = @_ });
$promise = $db->zrevrank_p($key, $member);
Determines the index of a member in a sorted set, with scores ordered from high to low. Same rank energy, just counting from the other end ๐
https://redis.io/commands/zrevrank ๐
zscore ๐
$res = $db->zscore($key, $member);
$db = $db->zscore($key, $member, sub { my ($db, $err, $res) = @_ });
$promise = $db->zscore_p($key, $member);
Gets the score associated with the given member in a sorted set. One member, one number, zero small talk โจ
https://redis.io/commands/zscore ๐
zunionstoreโ bestie this is the multiple sorted sets girlie ๐ she takes a bunch of sorted sets, smooshes them together, and drops the whole glowing result into a brand-new key. iconic behaviour, no cap โจ
Three ways to call her, depending on your whole vibe:
$res = $db->zunionstore($destination, $numkeys, $key [key ...], [WEIGHTS weight [weight ...]], [AGGREGATE SUM|MIN|MAX]);
$db = $db->zunionstore($destination, $numkeys, $key [key ...], [WEIGHTS weight [weight ...]], [AGGREGATE SUM|MIN|MAX], sub { my ($db, $err, $res) = @_ });
$promise = $db->zunionstore_p($destination, $numkeys, $key [key ...], [WEIGHTS weight [weight ...]], [AGGREGATE SUM|MIN|MAX]);
So like โ $destination is where the shiny new set lands ๐, $numkeys tells her how many $keys to expect, and then the optional WEIGHTS weight [weight ...] and AGGREGATE SUM|MIN|MAX bits let you finesse how the scores get combined. Pick the plain call for a straight-up $res, pass a sub { my ($db, $err, $res) = @_ } callback if you're feeling async, or grab the _p version when you want a $promise to hold onto. choose your fighter ๐ซถ
Heads up bestie โ the official tea is at <https://redis.io/commands/zunionstore>, go sip โ๏ธ
๐ SEE ALSO ๐
Mojo::Redisโ the mothership ๐ if you're lost, start there, she knows everything, iykyk ๐
and that's the whole page, bestie!! you made it to the end ๐๐ฆ this little manual page lives in perl v5.42.2, dated 2026-02-15, and it's a User Contributed Perl Documentation situation โ so go forth, union those sorted sets, and slay ๐ โจ๐ periodt ๐
๐ฆ where this page comes from
- alpine 3.24: perl-mojo-redis-doc 3.29-r1 ยท Artistic-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms