-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add columns.lua which return all columns of the table
- Loading branch information
1 parent
5192975
commit cbeccbb
Showing
6 changed files
with
76 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
local _t_ = '_T_' | ||
local _t_n_ = '_T_N_' | ||
local na = #ARGV | ||
local level = redis.LOG_NOTICE | ||
local v = {} | ||
|
||
local table_exists = function(t) | ||
return 1 == redis.call('sismember', _t_n_, t) | ||
end | ||
|
||
if (0 == na) then | ||
v = {0, 'should provides table name argument(>=1)'} | ||
redis.log(level, v[#v]) | ||
return v | ||
end | ||
|
||
local t = ARGV[1] | ||
if (not table_exists(t)) then | ||
v = {0, string.format('table %s does not exists', t)} | ||
redis.log(level, v[#v]) | ||
return v | ||
end | ||
|
||
local d = string.format(_t_..'[%s]_C_', t) | ||
local cc = redis.call('smembers', d) | ||
if (nil == cc) then | ||
v = {0, 'can not find column defition'} | ||
else | ||
v = {#cc, cc} | ||
end | ||
|
||
return v | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters