node.js - Unable to ltrim when Redis list is having only one record -


i try trim records in redis queue using following command. unfortunately, unable trim if there 1 item in list.

ltrim key, -1, 0; 

for ltrim key start_index stop_index command, index 0 based. 0 index of first element, , -1 index of last element. if start_index larger stop_index, redis clears list, i.e. deletes key.

base on above definition, let's take @ command:

ltrim key -1 0 

the start_index -1, i.e. index of last element, , stop_index 0, i.e. index of first element.

if list has more 1 elements, start_index larger stop_index. in case, list / key deleted. however, if there's 1 element in list, both start_index , stop_index index of first (also last) element of list. command has same effect as: ltrim key 0 0. command, redis keeps first element (also element) of list, , list won't trimmed.

by way, want delete list? if do, call del key.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -