【问题标题】:How to create a new instance of a list using Rediska?如何使用 Rediska 创建列表的新实例?
【发布时间】:2011-06-29 21:42:42
【问题描述】:

我想在 Rediska 中创建一个 List 的新实例,但它似乎总是想使用一些全局列表。

例如,这是我用来创建新列表的代码:

  $firstList = new Rediska_Key_List('newList');
  $firstList[] = "firstList: first element";
  $firstList[] = "firstList: second element";

  $secondList = new Rediska_Key_List('newList');
  $secondList[] = "secondList: first element";
  $secondList[] = "secondList: second element";

  echo "$secondList[0] and $secondList[1]";

它将回显以下内容:firstList: first element and firstList: second element 推测这是因为 Rediska_Key_List 的第一个参数是同名的。我不需要这个。我只想创建一个新的无名实例。我不能将第一个参数留空。我希望脚本打印以下内容:

`secondList: first element and secondList: second element`

谢谢!

【问题讨论】:

  • 您是否尝试将第二个newList 更改为其他内容?有点愚蠢的问题,但我只是好奇。
  • 我有,但它对我尝试使用它的方式没有帮助。我有一个与redis交互的类。它创建一个包含两个元素的列表,一个值和一个时间。我希望这个列表是一个键的值。这对将属于哈希映射。很难解释,但我只能使用列表的一个实例,因为我想稍后将它添加为键的值。我还不想将它添加到 redis。

标签: php redis rediska


【解决方案1】:

如果你还不想存到redis中,只需要创建一个php表,然后在需要的时候复制到redis中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-04
    • 2019-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多