Skip to content

Instantly share code, notes, and snippets.

@agladysh
Created March 23, 2011 00:07
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/882374 to your computer and use it in GitHub Desktop.
Save agladysh/882374 to your computer and use it in GitHub Desktop.
EXISTS 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
local PNA = function(...) print(N .. ":", tstr(...)); N = N + 1 end
--------------------------------------------------------------------------------
-- Connect to Redis
--------------------------------------------------------------------------------
local R = assert(sidereal.connect("localhost", 6379))
--------------------------------------------------------------------------------
-- Fill data
--------------------------------------------------------------------------------
R:set("MYKEY", "value")
--------------------------------------------------------------------------------
-- This works
--------------------------------------------------------------------------------
P (R:exists("MYKEY"))
--> 1: true
PNA (R:exists("MISSINGKEY"))
--> 2: false
--------------------------------------------------------------------------------
-- This does not (note 6:, should be true, not false)
--------------------------------------------------------------------------------
R:pipeline()
P (R:exists("MYKEY"))
--> 3: {}
PNA (R:exists("MISSINGKEY"))
--> 4: {}
R:send_pipeline()
P (R:get_response())
--> 5: true
P (R:get_response())
--> 6: true -- Should be false!
--------------------------------------------------------------------------------
-- This does not either (note 10: should be {true, false})
--------------------------------------------------------------------------------
P (R:multi())
--> 7: "OK"
P (R:exists("MYKEY"))
--> 8: "QUEUED"
PNA (R:exists("MISSINGKEY"))
--> 9: "QUEUED"
P (R:exec())
--> 10: {1,0}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment