predis - redis 中取元素的方法?
迷茫
迷茫 2017-04-24 09:12:14
0
2
578

redis中有这样一个数组:
array =[1,2,3,4,5,6,7,8,9,0]

请问redis有没有这样一个方法实现如下:
functionName(array,0,5)
这个方法返回[1,2,3,4,5,6]
同时原来的array的结果变成[7,8,9,0]

请问redis中有这样的方法吗?
没有的话,最简单的实现是怎样的呢?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
洪涛

There is no similar method, it can be implemented like this:
lorange 0, 5 to get the first 6 elements

ltrim 7, -1 deletes the elements before the 7th element

There are also some boundary conditions, please check the documentation.

黄舟

No. In redis, only pop instructions perform deletion operations while taking values. The RANGE type operation can only take data within a specified range and cannot delete it at the same time.
Wouldn’t this need be solved by writing a few lines of PHP code? There is no need to be so entangled, right?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template