简体   繁体   English

如何使用 Rediska 创建列表的新实例?

[英]How to create a new instance of a list using Rediska?

I want to create a new instance of a List in Rediska, but it seems to always want to use some global list.我想在 Rediska 中创建一个 List 的新实例,但它似乎总是想使用一些全局列表。

For example, here is the code that I am using to create a new 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]";

It will echo the following: firstList: first element and firstList: second element Presumably, this is because the first argument of the Rediska_Key_List is the same name.它将回显以下内容: firstList: first element and firstList: second element大概是因为 Rediska_Key_List 的第一个参数是相同的名称。 I do not need this.我不需要这个。 I just want to create a new nameless instance.我只想创建一个新的无名实例。 I cannot leave the first argument blank.我不能将第一个参数留空。 I would like the script to print the following:我希望脚本打印以下内容:

`secondList: first element and secondList: second element`

Thanks!谢谢!

If you don't want to store it in redis yet, just create a php table, and afterward copy it to redis when needed如果您还不想将其存储在 redis 中,只需创建一个 php 表,然后在需要时将其复制到 redis

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM