=encoding utf8

=for comment POD_DERIVED_INDEX_GENERATED
The following documentation is automatically generated.  Please do not edit
this file, but rather the original, inline with Net::Async::Redis::Cluster
at lib/Net/Async/Redis/Cluster.pm
(on the system that originally ran this).
If you do edit this file, and don't want your changes to be removed, make
sure you change the first line.

=cut

=head1 NAME

Net::Async::Redis::Cluster - support for cluster routing

=head1 SYNOPSIS

 use IO::Async::Loop;
 use Net::Async::Redis::Cluster;
 my $loop = IO::Async::Loop->new;
 $loop->add(
  my $cluster = Net::Async::Redis::Cluster->new(
  )
 );
 await $cluster->bootstrap(
  host => 'redis.local',
 );
 print "Key: " . await $cluster->get('some_key');

=head1 DESCRIPTION

Provides access to a Redis cluster.

Usage is similar to L<Net::Async::Redis> with the addition of a L</bootstrap>
step to find the initial client nodes:

 $loop->add(
  my $cluster = Net::Async::Redis::Cluster->new(
  )
 );
 await $cluster->bootstrap(
  host => 'redis.local',
 );
 print "Key: " . await $cluster->get('some_key');

Note that this adds some overhead to lookups, so you may be better served
by options such as the L<https://github.com/twitter/twemproxy|twemproxy>
proxy routing dæmon, or a service mesh such as L<https://istio.io/|istio>.

=head1 METHODS

=head2 bootstrap

Connects to a Redis server and attempts to discover the cluster node configuration.

Usage:

 try {
  await $cluster->bootstrap(
   host => 'redis-primary.local',
   port => 6379,
  );
 } catch {
  $log->errorf('Unable to bootstrap the Redis cluster: %s', $@);
 }

=head2 hash_slot_for_key

Calculates the CRC16 hash slot for the given key.

Note that keys are expected as bytestrings, if you have a Unicode string
you'd likely want to convert to UTF-8 first.

=head2 replace_nodes

Swap the existing node configuration out for a new arrayref of nodes.

=head2 node_list

Returns a list of the currently-configured nodes.

=head2 node_for_slot

Returns the appropriate L<Net::Async::Redis::Cluster::Node|node> for the given hash key (slot).

=head1 INHERITED METHODS

=over 4

=item L<Net::Async::Redis::Commands>

L<acl_cat|Net::Async::Redis::Commands/acl_cat>, L<acl_deluser|Net::Async::Redis::Commands/acl_deluser>, L<acl_genpass|Net::Async::Redis::Commands/acl_genpass>, L<acl_getuser|Net::Async::Redis::Commands/acl_getuser>, L<acl_help|Net::Async::Redis::Commands/acl_help>, L<acl_list|Net::Async::Redis::Commands/acl_list>, L<acl_load|Net::Async::Redis::Commands/acl_load>, L<acl_log|Net::Async::Redis::Commands/acl_log>, L<acl_save|Net::Async::Redis::Commands/acl_save>, L<acl_setuser|Net::Async::Redis::Commands/acl_setuser>, L<acl_users|Net::Async::Redis::Commands/acl_users>, L<acl_whoami|Net::Async::Redis::Commands/acl_whoami>, L<append|Net::Async::Redis::Commands/append>, L<auth|Net::Async::Redis::Commands/auth>, L<bgrewriteaof|Net::Async::Redis::Commands/bgrewriteaof>, L<bgsave|Net::Async::Redis::Commands/bgsave>, L<bitcount|Net::Async::Redis::Commands/bitcount>, L<bitfield|Net::Async::Redis::Commands/bitfield>, L<bitop|Net::Async::Redis::Commands/bitop>, L<bitpos|Net::Async::Redis::Commands/bitpos>, L<blmove|Net::Async::Redis::Commands/blmove>, L<blpop|Net::Async::Redis::Commands/blpop>, L<brpop|Net::Async::Redis::Commands/brpop>, L<brpoplpush|Net::Async::Redis::Commands/brpoplpush>, L<bzpopmax|Net::Async::Redis::Commands/bzpopmax>, L<bzpopmin|Net::Async::Redis::Commands/bzpopmin>, L<client_caching|Net::Async::Redis::Commands/client_caching>, L<client_getname|Net::Async::Redis::Commands/client_getname>, L<client_getredir|Net::Async::Redis::Commands/client_getredir>, L<client_id|Net::Async::Redis::Commands/client_id>, L<client_info|Net::Async::Redis::Commands/client_info>, L<client_kill|Net::Async::Redis::Commands/client_kill>, L<client_list|Net::Async::Redis::Commands/client_list>, L<client_pause|Net::Async::Redis::Commands/client_pause>, L<client_reply|Net::Async::Redis::Commands/client_reply>, L<client_setname|Net::Async::Redis::Commands/client_setname>, L<client_tracking|Net::Async::Redis::Commands/client_tracking>, L<client_trackinginfo|Net::Async::Redis::Commands/client_trackinginfo>, L<client_unblock|Net::Async::Redis::Commands/client_unblock>, L<client_unpause|Net::Async::Redis::Commands/client_unpause>, L<cluster_addslots|Net::Async::Redis::Commands/cluster_addslots>, L<cluster_bumpepoch|Net::Async::Redis::Commands/cluster_bumpepoch>, L<cluster_count_failure_reports|Net::Async::Redis::Commands/cluster_count_failure_reports>, L<cluster_countkeysinslot|Net::Async::Redis::Commands/cluster_countkeysinslot>, L<cluster_delslots|Net::Async::Redis::Commands/cluster_delslots>, L<cluster_failover|Net::Async::Redis::Commands/cluster_failover>, L<cluster_flushslots|Net::Async::Redis::Commands/cluster_flushslots>, L<cluster_forget|Net::Async::Redis::Commands/cluster_forget>, L<cluster_getkeysinslot|Net::Async::Redis::Commands/cluster_getkeysinslot>, L<cluster_info|Net::Async::Redis::Commands/cluster_info>, L<cluster_keyslot|Net::Async::Redis::Commands/cluster_keyslot>, L<cluster_meet|Net::Async::Redis::Commands/cluster_meet>, L<cluster_myid|Net::Async::Redis::Commands/cluster_myid>, L<cluster_nodes|Net::Async::Redis::Commands/cluster_nodes>, L<cluster_replicas|Net::Async::Redis::Commands/cluster_replicas>, L<cluster_replicate|Net::Async::Redis::Commands/cluster_replicate>, L<cluster_reset|Net::Async::Redis::Commands/cluster_reset>, L<cluster_saveconfig|Net::Async::Redis::Commands/cluster_saveconfig>, L<cluster_set_config_epoch|Net::Async::Redis::Commands/cluster_set_config_epoch>, L<cluster_setslot|Net::Async::Redis::Commands/cluster_setslot>, L<cluster_slaves|Net::Async::Redis::Commands/cluster_slaves>, L<cluster_slots|Net::Async::Redis::Commands/cluster_slots>, L<command|Net::Async::Redis::Commands/command>, L<command_count|Net::Async::Redis::Commands/command_count>, L<command_getkeys|Net::Async::Redis::Commands/command_getkeys>, L<command_info|Net::Async::Redis::Commands/command_info>, L<config_get|Net::Async::Redis::Commands/config_get>, L<config_resetstat|Net::Async::Redis::Commands/config_resetstat>, L<config_rewrite|Net::Async::Redis::Commands/config_rewrite>, L<config_set|Net::Async::Redis::Commands/config_set>, L<copy|Net::Async::Redis::Commands/copy>, L<dbsize|Net::Async::Redis::Commands/dbsize>, L<debug_object|Net::Async::Redis::Commands/debug_object>, L<debug_segfault|Net::Async::Redis::Commands/debug_segfault>, L<decr|Net::Async::Redis::Commands/decr>, L<decrby|Net::Async::Redis::Commands/decrby>, L<del|Net::Async::Redis::Commands/del>, L<discard|Net::Async::Redis::Commands/discard>, L<dump|Net::Async::Redis::Commands/dump>, L<echo|Net::Async::Redis::Commands/echo>, L<eval|Net::Async::Redis::Commands/eval>, L<evalsha|Net::Async::Redis::Commands/evalsha>, L<exec|Net::Async::Redis::Commands/exec>, L<exists|Net::Async::Redis::Commands/exists>, L<expire|Net::Async::Redis::Commands/expire>, L<expireat|Net::Async::Redis::Commands/expireat>, L<flushall|Net::Async::Redis::Commands/flushall>, L<flushdb|Net::Async::Redis::Commands/flushdb>, L<geoadd|Net::Async::Redis::Commands/geoadd>, L<geodist|Net::Async::Redis::Commands/geodist>, L<geohash|Net::Async::Redis::Commands/geohash>, L<geopos|Net::Async::Redis::Commands/geopos>, L<georadius|Net::Async::Redis::Commands/georadius>, L<georadiusbymember|Net::Async::Redis::Commands/georadiusbymember>, L<geosearch|Net::Async::Redis::Commands/geosearch>, L<geosearchstore|Net::Async::Redis::Commands/geosearchstore>, L<get|Net::Async::Redis::Commands/get>, L<getbit|Net::Async::Redis::Commands/getbit>, L<getdel|Net::Async::Redis::Commands/getdel>, L<getex|Net::Async::Redis::Commands/getex>, L<getrange|Net::Async::Redis::Commands/getrange>, L<getset|Net::Async::Redis::Commands/getset>, L<hdel|Net::Async::Redis::Commands/hdel>, L<hello|Net::Async::Redis::Commands/hello>, L<hexists|Net::Async::Redis::Commands/hexists>, L<hget|Net::Async::Redis::Commands/hget>, L<hgetall|Net::Async::Redis::Commands/hgetall>, L<hincrby|Net::Async::Redis::Commands/hincrby>, L<hincrbyfloat|Net::Async::Redis::Commands/hincrbyfloat>, L<hkeys|Net::Async::Redis::Commands/hkeys>, L<hlen|Net::Async::Redis::Commands/hlen>, L<hmget|Net::Async::Redis::Commands/hmget>, L<hmset|Net::Async::Redis::Commands/hmset>, L<hrandfield|Net::Async::Redis::Commands/hrandfield>, L<hscan|Net::Async::Redis::Commands/hscan>, L<hset|Net::Async::Redis::Commands/hset>, L<hsetnx|Net::Async::Redis::Commands/hsetnx>, L<hstrlen|Net::Async::Redis::Commands/hstrlen>, L<hvals|Net::Async::Redis::Commands/hvals>, L<incr|Net::Async::Redis::Commands/incr>, L<incrby|Net::Async::Redis::Commands/incrby>, L<incrbyfloat|Net::Async::Redis::Commands/incrbyfloat>, L<info|Net::Async::Redis::Commands/info>, L<keys|Net::Async::Redis::Commands/keys>, L<lastsave|Net::Async::Redis::Commands/lastsave>, L<latency_doctor|Net::Async::Redis::Commands/latency_doctor>, L<latency_graph|Net::Async::Redis::Commands/latency_graph>, L<latency_help|Net::Async::Redis::Commands/latency_help>, L<latency_history|Net::Async::Redis::Commands/latency_history>, L<latency_latest|Net::Async::Redis::Commands/latency_latest>, L<latency_reset|Net::Async::Redis::Commands/latency_reset>, L<lindex|Net::Async::Redis::Commands/lindex>, L<linsert|Net::Async::Redis::Commands/linsert>, L<llen|Net::Async::Redis::Commands/llen>, L<lmove|Net::Async::Redis::Commands/lmove>, L<lolwut|Net::Async::Redis::Commands/lolwut>, L<lpop|Net::Async::Redis::Commands/lpop>, L<lpos|Net::Async::Redis::Commands/lpos>, L<lpush|Net::Async::Redis::Commands/lpush>, L<lpushx|Net::Async::Redis::Commands/lpushx>, L<lrange|Net::Async::Redis::Commands/lrange>, L<lrem|Net::Async::Redis::Commands/lrem>, L<lset|Net::Async::Redis::Commands/lset>, L<ltrim|Net::Async::Redis::Commands/ltrim>, L<memory_doctor|Net::Async::Redis::Commands/memory_doctor>, L<memory_help|Net::Async::Redis::Commands/memory_help>, L<memory_malloc_stats|Net::Async::Redis::Commands/memory_malloc_stats>, L<memory_purge|Net::Async::Redis::Commands/memory_purge>, L<memory_stats|Net::Async::Redis::Commands/memory_stats>, L<memory_usage|Net::Async::Redis::Commands/memory_usage>, L<mget|Net::Async::Redis::Commands/mget>, L<migrate|Net::Async::Redis::Commands/migrate>, L<module_list|Net::Async::Redis::Commands/module_list>, L<module_load|Net::Async::Redis::Commands/module_load>, L<module_unload|Net::Async::Redis::Commands/module_unload>, L<monitor|Net::Async::Redis::Commands/monitor>, L<move|Net::Async::Redis::Commands/move>, L<mset|Net::Async::Redis::Commands/mset>, L<msetnx|Net::Async::Redis::Commands/msetnx>, L<multi|Net::Async::Redis::Commands/multi>, L<object|Net::Async::Redis::Commands/object>, L<persist|Net::Async::Redis::Commands/persist>, L<pexpire|Net::Async::Redis::Commands/pexpire>, L<pexpireat|Net::Async::Redis::Commands/pexpireat>, L<pfadd|Net::Async::Redis::Commands/pfadd>, L<pfcount|Net::Async::Redis::Commands/pfcount>, L<pfmerge|Net::Async::Redis::Commands/pfmerge>, L<ping|Net::Async::Redis::Commands/ping>, L<psetex|Net::Async::Redis::Commands/psetex>, L<psubscribe|Net::Async::Redis::Commands/psubscribe>, L<psync|Net::Async::Redis::Commands/psync>, L<pttl|Net::Async::Redis::Commands/pttl>, L<publish|Net::Async::Redis::Commands/publish>, L<pubsub|Net::Async::Redis::Commands/pubsub>, L<punsubscribe|Net::Async::Redis::Commands/punsubscribe>, L<quit|Net::Async::Redis::Commands/quit>, L<randomkey|Net::Async::Redis::Commands/randomkey>, L<readonly|Net::Async::Redis::Commands/readonly>, L<readwrite|Net::Async::Redis::Commands/readwrite>, L<rename|Net::Async::Redis::Commands/rename>, L<renamenx|Net::Async::Redis::Commands/renamenx>, L<replicaof|Net::Async::Redis::Commands/replicaof>, L<reset|Net::Async::Redis::Commands/reset>, L<restore|Net::Async::Redis::Commands/restore>, L<role|Net::Async::Redis::Commands/role>, L<rpop|Net::Async::Redis::Commands/rpop>, L<rpoplpush|Net::Async::Redis::Commands/rpoplpush>, L<rpush|Net::Async::Redis::Commands/rpush>, L<rpushx|Net::Async::Redis::Commands/rpushx>, L<sadd|Net::Async::Redis::Commands/sadd>, L<save|Net::Async::Redis::Commands/save>, L<scan|Net::Async::Redis::Commands/scan>, L<scard|Net::Async::Redis::Commands/scard>, L<script_debug|Net::Async::Redis::Commands/script_debug>, L<script_exists|Net::Async::Redis::Commands/script_exists>, L<script_flush|Net::Async::Redis::Commands/script_flush>, L<script_kill|Net::Async::Redis::Commands/script_kill>, L<script_load|Net::Async::Redis::Commands/script_load>, L<sdiff|Net::Async::Redis::Commands/sdiff>, L<sdiffstore|Net::Async::Redis::Commands/sdiffstore>, L<select|Net::Async::Redis::Commands/select>, L<set|Net::Async::Redis::Commands/set>, L<setbit|Net::Async::Redis::Commands/setbit>, L<setex|Net::Async::Redis::Commands/setex>, L<setnx|Net::Async::Redis::Commands/setnx>, L<setrange|Net::Async::Redis::Commands/setrange>, L<shutdown|Net::Async::Redis::Commands/shutdown>, L<sinter|Net::Async::Redis::Commands/sinter>, L<sinterstore|Net::Async::Redis::Commands/sinterstore>, L<sismember|Net::Async::Redis::Commands/sismember>, L<slaveof|Net::Async::Redis::Commands/slaveof>, L<slowlog|Net::Async::Redis::Commands/slowlog>, L<smembers|Net::Async::Redis::Commands/smembers>, L<smismember|Net::Async::Redis::Commands/smismember>, L<smove|Net::Async::Redis::Commands/smove>, L<sort|Net::Async::Redis::Commands/sort>, L<spop|Net::Async::Redis::Commands/spop>, L<srandmember|Net::Async::Redis::Commands/srandmember>, L<srem|Net::Async::Redis::Commands/srem>, L<sscan|Net::Async::Redis::Commands/sscan>, L<stralgo|Net::Async::Redis::Commands/stralgo>, L<strlen|Net::Async::Redis::Commands/strlen>, L<subscribe|Net::Async::Redis::Commands/subscribe>, L<sunion|Net::Async::Redis::Commands/sunion>, L<sunionstore|Net::Async::Redis::Commands/sunionstore>, L<swapdb|Net::Async::Redis::Commands/swapdb>, L<sync|Net::Async::Redis::Commands/sync>, L<time|Net::Async::Redis::Commands/time>, L<touch|Net::Async::Redis::Commands/touch>, L<ttl|Net::Async::Redis::Commands/ttl>, L<type|Net::Async::Redis::Commands/type>, L<unlink|Net::Async::Redis::Commands/unlink>, L<unsubscribe|Net::Async::Redis::Commands/unsubscribe>, L<unwatch|Net::Async::Redis::Commands/unwatch>, L<wait|Net::Async::Redis::Commands/wait>, L<watch|Net::Async::Redis::Commands/watch>, L<xack|Net::Async::Redis::Commands/xack>, L<xadd|Net::Async::Redis::Commands/xadd>, L<xautoclaim|Net::Async::Redis::Commands/xautoclaim>, L<xclaim|Net::Async::Redis::Commands/xclaim>, L<xdel|Net::Async::Redis::Commands/xdel>, L<xgroup|Net::Async::Redis::Commands/xgroup>, L<xinfo|Net::Async::Redis::Commands/xinfo>, L<xlen|Net::Async::Redis::Commands/xlen>, L<xpending|Net::Async::Redis::Commands/xpending>, L<xrange|Net::Async::Redis::Commands/xrange>, L<xread|Net::Async::Redis::Commands/xread>, L<xreadgroup|Net::Async::Redis::Commands/xreadgroup>, L<xrevrange|Net::Async::Redis::Commands/xrevrange>, L<xtrim|Net::Async::Redis::Commands/xtrim>, L<zadd|Net::Async::Redis::Commands/zadd>, L<zcard|Net::Async::Redis::Commands/zcard>, L<zcount|Net::Async::Redis::Commands/zcount>, L<zdiff|Net::Async::Redis::Commands/zdiff>, L<zdiffstore|Net::Async::Redis::Commands/zdiffstore>, L<zincrby|Net::Async::Redis::Commands/zincrby>, L<zinter|Net::Async::Redis::Commands/zinter>, L<zinterstore|Net::Async::Redis::Commands/zinterstore>, L<zlexcount|Net::Async::Redis::Commands/zlexcount>, L<zmscore|Net::Async::Redis::Commands/zmscore>, L<zpopmax|Net::Async::Redis::Commands/zpopmax>, L<zpopmin|Net::Async::Redis::Commands/zpopmin>, L<zrandmember|Net::Async::Redis::Commands/zrandmember>, L<zrange|Net::Async::Redis::Commands/zrange>, L<zrangebylex|Net::Async::Redis::Commands/zrangebylex>, L<zrangebyscore|Net::Async::Redis::Commands/zrangebyscore>, L<zrangestore|Net::Async::Redis::Commands/zrangestore>, L<zrank|Net::Async::Redis::Commands/zrank>, L<zrem|Net::Async::Redis::Commands/zrem>, L<zremrangebylex|Net::Async::Redis::Commands/zremrangebylex>, L<zremrangebyrank|Net::Async::Redis::Commands/zremrangebyrank>, L<zremrangebyscore|Net::Async::Redis::Commands/zremrangebyscore>, L<zrevrange|Net::Async::Redis::Commands/zrevrange>, L<zrevrangebylex|Net::Async::Redis::Commands/zrevrangebylex>, L<zrevrangebyscore|Net::Async::Redis::Commands/zrevrangebyscore>, L<zrevrank|Net::Async::Redis::Commands/zrevrank>, L<zscan|Net::Async::Redis::Commands/zscan>, L<zscore|Net::Async::Redis::Commands/zscore>, L<zunion|Net::Async::Redis::Commands/zunion>, L<zunionstore|Net::Async::Redis::Commands/zunionstore>

=item L<IO::Async::Notifier>

L<add_child|IO::Async::Notifier/add_child>, L<adopt_future|IO::Async::Notifier/adopt_future>, L<adopted_futures|IO::Async::Notifier/adopted_futures>, L<can_event|IO::Async::Notifier/can_event>, L<children|IO::Async::Notifier/children>, L<configure|IO::Async::Notifier/configure>, L<configure_unknown|IO::Async::Notifier/configure_unknown>, L<debug_printf|IO::Async::Notifier/debug_printf>, L<get_loop|IO::Async::Notifier/get_loop>, L<invoke_error|IO::Async::Notifier/invoke_error>, L<invoke_event|IO::Async::Notifier/invoke_event>, L<loop|IO::Async::Notifier/loop>, L<make_event_cb|IO::Async::Notifier/make_event_cb>, L<maybe_invoke_event|IO::Async::Notifier/maybe_invoke_event>, L<maybe_make_event_cb|IO::Async::Notifier/maybe_make_event_cb>, L<new|IO::Async::Notifier/new>, L<notifier_name|IO::Async::Notifier/notifier_name>, L<parent|IO::Async::Notifier/parent>, L<remove_child|IO::Async::Notifier/remove_child>, L<remove_from_parent|IO::Async::Notifier/remove_from_parent>

=back

=head1 AUTHOR

Tom Molesworth C<< <TEAM@cpan.org> >> plus contributors as mentioned in
L<Net::Async::Redis/CONTRIBUTORS>.

=head1 LICENSE

Copyright Tom Molesworth and others 2015-2021.
Licensed under the same terms as Perl itself.

