NAME

Postgredis -- PostgreSQL and Redis mashup

SYNOPSIS

     my $db = Postgredis->new('test');
     $db->set(favorite_color => "blue");
     $db->hset("joe", name => "Joe", age => 50 );

DESCRIPTION

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.

METHODS

Most of the methods are self explanatory -- see http://redis.io for further descriptions.

Database operations

    maybe_init($s)
    flushdb($s)

Key operations

    set($s,$key,$value)
    get($s,$k)
    del($s,$k)
    keys($s,$pat)
    exists($s,$k)

Hash operations

    hset($s,$key,$hkey,$value)
    hdel($s,$key,$hkey)
    hget($s,$key,$hkey)
    hgetall($s,$key)

Set operations

    sadd($s,$key,$value)
    srem($s,$key,$value)
    smembers($s,$k)

Sorted set operations

    zadd($s,$key,$val,$score)
    zscore($s,$key,$val)
    zrem($s,$key,$val)
    zrangebyscore($s,$key,$min,$max)

String operations

    incr($s,$k)

MOTIVATION

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.

SEE ALSO

RedisDB, Mojo::Pg

AUTHOR

Brian Duggan bduggan@cpan.org