mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2024-11-29 01:33:46 +00:00
Add and load dele_tag_if_in_set Lua script.
This commit is contained in:
parent
af7443c48b
commit
de00a4b469
4 changed files with 37 additions and 0 deletions
|
@ -53,6 +53,7 @@ configure_file(
|
|||
)
|
||||
set(LUA_SCRIPTS
|
||||
tag_if_in_set.lua
|
||||
dele_tag_if_in_set.lua
|
||||
)
|
||||
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
|
|
|
@ -117,6 +117,7 @@ namespace dindb {
|
|||
}
|
||||
|
||||
m_tag_if_in_set = m_redis.make_script(read_script(m_lua_script_paths, "tag_if_in_set.lua"));
|
||||
m_dele_tag_if_in_set = m_redis.make_script(read_script(m_lua_script_paths, "dele_tag_if_in_set.lua"));
|
||||
}
|
||||
|
||||
void BackendRedis::disconnect() {
|
||||
|
@ -132,15 +133,19 @@ namespace dindb {
|
|||
}
|
||||
|
||||
void BackendRedis::delete_tags (const std::vector<FileIDType>& parFiles, const std::vector<boost::string_ref>& parTags, GroupIDType parSet) {
|
||||
dindb::delete_tags(m_redis, m_dele_tag_if_in_set, parFiles, parTags, parSet);
|
||||
}
|
||||
|
||||
void BackendRedis::delete_tags (const std::vector<std::string>& parRegexes, const std::vector<boost::string_ref>& parTags, GroupIDType parSet) {
|
||||
dindb::delete_tags(m_redis, m_dele_tag_if_in_set, parRegexes, parTags, parSet);
|
||||
}
|
||||
|
||||
void BackendRedis::delete_all_tags (const std::vector<FileIDType>& parFiles, GroupIDType parSet) {
|
||||
dindb::delete_all_tags(m_redis, m_dele_tag_if_in_set, parFiles, parSet);
|
||||
}
|
||||
|
||||
void BackendRedis::delete_all_tags (const std::vector<std::string>& parRegexes, GroupIDType parSet) {
|
||||
dindb::delete_all_tags(m_redis, m_dele_tag_if_in_set, parRegexes, parSet);
|
||||
}
|
||||
|
||||
void BackendRedis::delete_group (const std::vector<uint32_t>& parIDs, ConfirmDeleCallback parConf) {
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace dindb {
|
|||
private:
|
||||
redis::Command m_redis;
|
||||
redis::Script m_tag_if_in_set;
|
||||
redis::Script m_dele_tag_if_in_set;
|
||||
dincore::SearchPaths m_lua_script_paths;
|
||||
uint16_t m_database;
|
||||
};
|
||||
|
|
30
src/backends/redis/dele_tag_if_in_set.lua
Normal file
30
src/backends/redis/dele_tag_if_in_set.lua
Normal file
|
@ -0,0 +1,30 @@
|
|||
-- Copyright 2015, 2016, Michele Santullo
|
||||
-- This file is part of "dindexer".
|
||||
--
|
||||
-- "dindexer" is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- "dindexer" is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
local tag_key = KEYS[1]
|
||||
local file_key = KEYS[2]
|
||||
local group_key = ARGV[1]
|
||||
|
||||
if group_key == "" then
|
||||
return redis.call("SREM", tag_key, file_key)
|
||||
else
|
||||
local found_group_key = redis.call("HGET", file_key, "group_id")
|
||||
if found_group_key == group_key then
|
||||
return redis.call("SREM", tag_key, file_key)
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue