Mojo::R...Database(3)

๐Ÿ“ฆ version 3.29, in alpine 3.24

๐ŸŽ€ 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 in bitfield_p really 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]
  • LIST
  • GETNAME
  • PAUSE timeout
  • REPLY [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
  • COUNT
  • GETKEYS
  • INFO 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 supported multi_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, it croak()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.


$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