1

我正在尝试使用 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...'),
)

谢谢!

4

0 回答 0