NAME
ShardedKV::Storage::Redis - Abstract base class for storing k/v pairs in Redis
VERSION
version 0.18
SYNOPSIS
# use a subclass instead
DESCRIPTION
This class consumes the ShardedKV::Storage role. It is an abstract base class for storing key-value pairs in Redis. It does not actually implement the get()
and set()
methods and does not impose a Redis value type. Different subclasses of this class are expected to represent different storages for distinct Redis value types.
PUBLIC ATTRIBUTES
redis_connect_str
A hostname:port string pointing at the Redis for this shard. Required.
redis_retry_every
The amount of time the Redis
object should wait between reconnect attempts, in milliseconds. Default 500.
redis_reconnect_timeout
If set, the amount of time the Redis
object should try reconnecting for, in seconds. If 0, do not attempt to reconnect.
redis
The Redis
object that represents the connection. Will be generated from the redis_connect_str
attribute and may be reset/reconnected at any time.
expiration_time
Base key expiration time to use in seconds. Defaults to undef / not expiring at all.
expiration_time_jitter
Additional random jitter to add to the expiration time. Defaults to 0. Don't set to undef to disable, set to 0 to disable.
database_number
Indicates the number of the Redis database to use for this shard. If undef/non-existant, no specific database will be selected, so the Redis server will use the default.
PUBLIC METHODS
delete
Implemented in the base class, this method deletes the given key from the Redis shard.
get
Not implemented in the base class. This method is supposed to fetch a value back from Redis. Beware: Depending on the ShardedKV::Storage::Redis
subclass, the reference type that this method returns may vary. For example, if you use ShardedKV::Storage::Redis::String
, the return value will be a scalar reference to a string. For ShardedKV::String::Redis::Hash
, the return value is unsurprisingly a hash reference.
set
The counterpart to get
. Expects values as second argument. The value must be of the same reference type that is returned by get()
.
SEE ALSO
-
# vim: ts=2 sw=2 et
AUTHORS
Steffen Mueller <smueller@cpan.org>
Nick Perez <nperez@cpan.org>
Damian Gryski <dgryski@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Steffen Mueller.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.