Skip to content

Instantly share code, notes, and snippets.

@agladysh
Created October 24, 2010 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agladysh/642968 to your computer and use it in GitHub Desktop.
Save agladysh/642968 to your computer and use it in GitHub Desktop.
DEL with key list is broken
pcall(require, 'luarocks.require')
local sidereal = require 'sidereal' -- sudo luarocks install sidereal --from=http://luarocks.org/repositories/rocks-cvs
--------------------------------------------------------------------------------
-- Some value printing code
--------------------------------------------------------------------------------
require 'lua-nucleo.module' -- sudo luarocks install lua-nucleo
require 'lua-nucleo.strict'
local tstr = import 'lua-nucleo/tstr.lua' { 'tstr' } -- Lua value to string
local N = 1
local P = function(...) print(N .. ":", tstr(assert(...))); N = N + 1 end
--------------------------------------------------------------------------------
-- Connect to Redis
--------------------------------------------------------------------------------
local R = assert(sidereal.connect("localhost", 6379))
R:flushdb()
--------------------------------------------------------------------------------
-- Fill data
--------------------------------------------------------------------------------
local init = function()
assert(R:set("ONE", "one"))
assert(R:set("TWO", "two"))
end
--------------------------------------------------------------------------------
-- This works
--------------------------------------------------------------------------------
init()
P (R:keys("*"))
P (R:del("ONE TWO"))
P (R:keys("*"))
--[[-->
1: {"TWO","ONE"}
2: 2
3: {}
redis> monitor
+1287885125.12932 "KEYS" "*"
+1287885125.13170 "DEL" "ONE" "TWO"
+1287885125.13544 "KEYS" "*"
--]]
--------------------------------------------------------------------------------
-- This does not
--------------------------------------------------------------------------------
init()
P (R:keys("*"))
P (R:del({"ONE", "TWO"}))
P (R:keys("*"))
--[[-->
4: {"TWO","ONE"}
5: 0
6: {"TWO","ONE"}
redis> monitor
+1287885125.14731 "KEYS" "*"
+1287885125.14932 "DEL" "table:" "0x9c12310"
+1287885125.15094 "KEYS" "*"
--]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment