Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
158 additions
and
55 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,32 @@ | ||
local first_updated_at = table.remove(ARGV, 1) | ||
local last_updated_at = table.remove(ARGV, 1) | ||
local file = table.remove(ARGV, 1) | ||
local file_hash = table.remove(ARGV, 1) | ||
local ttl = table.remove(ARGV, 1) | ||
local file_length = table.remove(ARGV, 1) | ||
local hash_key = table.remove(KEYS, 1) | ||
redis.call('HMSET', hash_key, 'last_updated_at', last_updated_at, 'file', file, 'file_hash', file_hash, 'file_length', file_length) | ||
redis.call('HSETNX', hash_key, 'first_updated_at', first_updated_at) | ||
for i, key in ipairs(KEYS) do | ||
if ARGV[i] == '-1' then | ||
redis.call("HSET", hash_key, key, ARGV[i]) | ||
else | ||
redis.call("HINCRBY", hash_key, key, ARGV[i]) | ||
local hash_values_array = cjson.decode(redis.call('get', (KEYS[1]))) | ||
redis.call('DEL', KEYS[1]) | ||
for i, hash_values in ipairs(hash_values_array) do | ||
local function remove(key) | ||
local val = hash_values[key] | ||
hash_values[key] = nil | ||
return val | ||
end | ||
local first_updated_at = remove('first_updated_at') | ||
local last_updated_at = remove('last_updated_at') | ||
local file = remove('file') | ||
local file_hash = remove('file_hash') | ||
local ttl = remove('ttl') | ||
local file_length = remove('file_length') | ||
local hash_key = remove('hash_key') | ||
redis.call('HMSET', hash_key, 'file', file, 'file_hash', file_hash, 'file_length', file_length) | ||
|
||
if (last_updated_at ~= cjson.null) then | ||
redis.call('HSET', hash_key, 'last_updated_at', last_updated_at) | ||
end | ||
redis.call('HSETNX', hash_key, 'first_updated_at', first_updated_at) | ||
for line, coverage in pairs(hash_values) do | ||
if coverage == '-1' then | ||
redis.call("HSET", hash_key, line, coverage) | ||
else | ||
redis.call("HINCRBY", hash_key, line, coverage) | ||
end | ||
end | ||
if ttl > -1 then | ||
redis.call("EXPIRE", hash_key, ttl) | ||
end | ||
end | ||
if ttl ~= '-1' then | ||
redis.call("EXPIRE", hash_key, ttl) | ||
end |
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,5 @@ | ||
inspect = require "inspect" | ||
cjson = require 'cjson' | ||
require './lua/test/redis-call' | ||
|
||
|
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
inspect = require "inspect" | ||
require './lua/test/redis-call' | ||
require './lua/test/bootstrap' | ||
|
||
|
||
KEYS = {} | ||
|
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