使用Redis创建通知结构

时间:2014-12-07 14:44:29

标签: php redis phpredis

我正在尝试使用Redis创建“通知”,目前正在使用PHPRedis。我想为每个用户(通过USER_ID)存储多个通知,其中包含多个“key => value”。

通知可能看起来像(作为PHP数组):

$notification = array('type' => 'item', 'time' => '123456789', 'type_id' => 10, 'message' => 'some example message here...');

那么,我怎样才能将此类通知推送到“用户”并让这些通知在1天后过期?

最终会得到类似的内容......只需通过USER_ID:

'user_id_1' => array(
  array('type' => 'item', 'time' => '123456789', 'type_id' => 10, 'message' => 'some example message here...'),
  array('type' => 'item', 'time' => '123456789', 'type_id' => 11, 'message' => 'some example message here...'),
  array('type' => 'item', 'time' => '123456789', 'type_id' => 12, 'message' => 'some example message here...'),
)

谢谢!

0 个答案:

没有答案