Postgredis -- PostgreSQL and Redis mashup
my $db = Postgredis->new('test'); $db->set(favorite_color => "blue"); $db->hset("joe", name => "Joe", age => 50 );
Postgredis is an experimental implementation of a subset of the Redis primitives using Postgres as a backend.
The interface provides methods corresponding to Redis commands which are translated into SQL queries on two tables. The two tables are a key-value table and a key-sortkey-value table. The values use the native JSON datatype in Postgres. For this, postgres 9.4 or higher is required.
Most of the methods are self explanatory -- see http://redis.io for further descriptions.
maybe_init($s) flushdb($s)
set($s,$key,$value) get($s,$k) del($s,$k) keys($s,$pat) exists($s,$k)
hset($s,$key,$hkey,$value) hdel($s,$key,$hkey) hget($s,$key,$hkey) hgetall($s,$key)
sadd($s,$key,$value) srem($s,$key,$value) smembers($s,$k)
zadd($s,$key,$val,$score) zscore($s,$key,$val) zrem($s,$key,$val) zrangebyscore($s,$key,$min,$max)
incr($s,$k)
The Redis primitives provide flexible representations of loosely structured data, but indexing and querying the data can be a challenge. PostgreSQL provides robust persistent data storage with flexible options for indexing and querying, but relational schema design may be costly and insufficiently flexible. Postgres as a backend is a compromise between the two.
RedisDB, Mojo::Pg
Brian Duggan bduggan@cpan.org
bduggan@cpan.org
To install Postgredis, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Postgredis
CPAN shell
perl -MCPAN -e shell install Postgredis
For more information on module installation, please visit the detailed CPAN module installation guide.