NAME
Mojo::Redis - Redis driver based on Mojo::IOLoop
SYNOPSIS
use Mojo::Redis;
my $redis = Mojo::Redis->new;
$redis->db->get_p("mykey")->then(sub {
print "mykey=$_[0]\n";
})->catch(sub {
warn "Could not fetch mykey: $_[0]";
})->wait;
DESCRIPTION
Mojo::Redis is a Redis driver that use the Mojo::IOLoop, which makes it integrate easily with the Mojolicious framework.
It tries to mimic the same interface as Mojo::Pg, Mojo::mysql and Mojo::SQLite, but the methods for talking to the database vary.
This module is in no way compatible with the 1.xx version of Mojo::Redis and this version also tries to fix a lot of the confusing methods in Mojo::Redis2 related to pubsub.
This module is currently EXPERIMENTAL, and bad design decisions will be fixed without warning. Please report at https://github.com/jhthorsen/mojo-redis/issues if you find this module useful, annoying or if you simply find bugs. Feedback can also be sent to jhthorsen@cpan.org
.
ATTRIBUTES
max_connections
$int = $self->max_connections;
$self = $self->max_connections(5);
Maximum number of idle database handles to cache for future use, defaults to 5. (Default is subject to change)
protocol_class
$str = $self->protocol_class;
$self = $self->protocol_class("Protocol::Redis::XS");
Default to Protocol::Redis::XS if the optional module is available, or falls back to Protocol::Redis.
pubsub
$pubsub = $self->pubsub;
Lazy builds an instance of Mojo::Redis::PubSub for this object, instead of returning a new instance like "db" does.
url
$url = $self->url;
$self = $self->url(Mojo::URL->new("redis://localhost/3"));
Holds an instance of Mojo::URL that describes how to connect to the Redis server.
METHODS
db
$db = $self->db;
Returns an instance of Mojo::Redis::Database.
cache
$cache = $self->cache(%attrs);
Returns an instance of Mojo::Redis::Cache.
cursor
$cursor = $self->cursor(@command);
Returns an instance of Mojo::Redis::Cursor with "command" in Mojo::Redis::Cursor set to the arguments passed. See "new" in Mojo::Redis::Cursor. for possible commands.
new
$self = Mojo::Redis->new("redis://localhost:6379/1");
$self = Mojo::Redis->new(\%attrs);
$self = Mojo::Redis->new(%attrs);
Object constructor. Can coerce a string into a Mojo::URL and set "url" if present.
txn
$db = $self->txn;
Returns an instance of Mojo::Redis::Transaction.
AUTHOR
Jan Henning Thorsen
COPYRIGHT AND LICENSE
Copyright (C) 2018, Jan Henning Thorsen.
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.