package Mojo::Redis::Cache;
use Mojo::Base -base;
use Mojo::JSON;
use Scalar::Util 'blessed';
use Storable ();
use Time::HiRes ();
use constant OFFLINE => $ENV{MOJO_REDIS_CACHE_OFFLINE};
has con
|| $self->default_expire;
my $key = join ':', '@M' => (ref($obj) || $obj), $method, Mojo::JSON::encode_json($args);
return $self->compute_p($key, $expire, sub { $obj->$method(@$args) });
}
sub _
=head2 deserialize
$cb = $cache->deserialize;
$cache = $cache->deserialize(\&Mojo::JSON::decode_json);
Holds a callback used to deserialize data from Redis.
=head2 namespace
$str = $cac
package Mojo::Redis::PubSub;
use Mojo::Base 'Mojo::EventEmitter';
use Mojo::JSON qw(from_json to_json);
use constant DEBUG => $ENV{MOJO_REDIS_DEBUG};
has connection => sub {
my $self = shift;
m
in constructor') };
sub channels_p { shift->db->call_p(qw(PUBSUB CHANNELS), @_) }
sub json { ++$_[0]{json}{$_[1]} and return $_[0] }
sub keyspace_listen {
my ($self, $cb) = (shift, pop);
;
return $cb;
}
sub notify_p {
my ($self, $name, $payload) = @_;
$payload = to_json $payload if $self->{json}{$name};
return $self->db->call_p(PUBLISH => $name, $payload);
}
sub notify { s