NAME
ShardedKV::Storage::Redis - Abstract base class for storing k/v pairs in Redis
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.
OBJECT ATTRIBUTES
redis_master_str
A hostname:port string pointing at the Redis master for this shard. Required.
redis_slave_strs
Array reference of hostname:port strings representing Redis slaves of the master. Currently unused, will eventually be used for either reading or master failover.
redis_master
The Redis
object that represents the master connection. Will be generated from the redis_master_str
attribute and may be reset/reconnected at any time.
expiration_time
Key expiration time to use in seconds.
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.
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
ShardedKV, ShardedKV::Storage, ShardedKV::Storage::Redis::String, ShardedKV::Storage::Redis::Hash
AUTHOR
Steffen Mueller <smueller@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2012 by Steffen Mueller
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.1 or, at your option, any later version of Perl 5 you may have available.