summaryrefslogtreecommitdiffstats
path: root/iredis/data/commands/lrem.md
diff options
context:
space:
mode:
Diffstat (limited to 'iredis/data/commands/lrem.md')
-rw-r--r--iredis/data/commands/lrem.md28
1 files changed, 28 insertions, 0 deletions
diff --git a/iredis/data/commands/lrem.md b/iredis/data/commands/lrem.md
new file mode 100644
index 0000000..c06dda7
--- /dev/null
+++ b/iredis/data/commands/lrem.md
@@ -0,0 +1,28 @@
+Removes the first `count` occurrences of elements equal to `element` from the
+list stored at `key`. The `count` argument influences the operation in the
+following ways:
+
+- `count > 0`: Remove elements equal to `element` moving from head to tail.
+- `count < 0`: Remove elements equal to `element` moving from tail to head.
+- `count = 0`: Remove all elements equal to `element`.
+
+For example, `LREM list -2 "hello"` will remove the last two occurrences of
+`"hello"` in the list stored at `list`.
+
+Note that non-existing keys are treated like empty lists, so when `key` does not
+exist, the command will always return `0`.
+
+@return
+
+@integer-reply: the number of removed elements.
+
+@examples
+
+```cli
+RPUSH mylist "hello"
+RPUSH mylist "hello"
+RPUSH mylist "foo"
+RPUSH mylist "hello"
+LREM mylist -2 "hello"
+LRANGE mylist 0 -1
+```