I\'m a bit confused with all the available storing options of Redis.
I want to do something simple and I don\'t want to over engineer it.
I\'m working with phpredis
Just for the folks looking for the PHP code, here is what I've ended up using:
// Create a post hash
$key = 'post:'.$post->getId();
$this->redis->hSet($key, 'data', serialize($post->toArray()));
// Add a post in the account posts SET
$this->redis->sAdd($account->getId().':posts', $post->getId());
// You can execute the above code as many time as you need
// to add an object in a SET
// Fetch the first $limit posts for this account
// SORT :posts BY nosort GET :post:*->data
$key = $account->getId().':posts';
$keys = $this->redis->sort($key, array(
'by' => 'nosort',
'limit' => array($offset, $limit),
'get' => 'post:*->data'
));
// All Good !
var_dump($keys);
I hope this will help some of you ;)