Skip to content

Instantly share code, notes, and snippets.

@agladysh
Created March 22, 2011 00:16
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/880515 to your computer and use it in GitHub Desktop.
Save agladysh/880515 to your computer and use it in GitHub Desktop.
SDIFF 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))
--------------------------------------------------------------------------------
-- Fill data
--------------------------------------------------------------------------------
R:sadd("MYSET1", "one")
R:sadd("MYSET1", "two")
R:sadd("MYSET2", "two")
R:sadd("MYSET1", "three")
--------------------------------------------------------------------------------
-- This works
--------------------------------------------------------------------------------
P (R:sdiff("MYSET1", "MYSET2"))
--> 1: {three=true,one=true}
--------------------------------------------------------------------------------
-- This does not
--------------------------------------------------------------------------------
R:pipeline()
P (R:sdiff("MYSET1", "MYSET2"))
--> 2: {}
R:send_pipeline()
P (R:get_response())
--> 3: true
--------------------------------------------------------------------------------
-- This does not either
--------------------------------------------------------------------------------
P (R:multi())
--> 4: "OK"
P (R:sdiff("MYSET1", "MYSET2"))
-->
--[[
lua: /usr/local/share/lua/5.1//sidereal.lua:488: bad argument #1 to 'ipairs' (table expected, got string)
stack traceback:
[C]: in function 'ipairs'
/usr/local/share/lua/5.1//sidereal.lua:488: in function </usr/local/share/lua/5.1//sidereal.lua:486>
(tail call): ?
check_sdiff_pipeline.lua:57: in main chunk
[C]: ?
--]]
P (R:exec())
--> (not reached)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment