librelist archives

« back to archive

[bamboo] 假删bug

[bamboo] 假删bug

From:
Uno Young
Date:
2012-03-22 @ 04:02
local fakedelFromRedis = function (self, id)
local model_key = id and getNameIdPattern2(self, id) or
getNameIdPattern(self)
local index_key = getIndexKey(self)

local fields = self.__fields
-- in redis, delete the associated foreign key-value store
for k, v in pairs(self) do
local fld = fields[k]
if fld and fld.foreign then
local key = model_key + ':' + k

>>>>
                      db:rename(key, 'DELETED:' + key)
==========
改为
      if db:exists(key) then
        db:rename(key, 'DELETED:' + key)
      end
<<<<<<<<

end
end

-- rename the key self
db:rename(model_key, 'DELETED:' + model_key)
-- delete the index in the global model index zset
-- when deleted, the instance's index cache was cleaned.
db:zremrangebyscore(index_key, self.id, self.id)
-- add to deleted collector
rdzset.add(dcollector,  model_key)

-- clear fulltext index
if isUsingFulltextIndex(self) then
clearFtIndexesOnDeletion(self)
end
if isUsingRuleIndex(self) then
updateIndexByRules(self, 'del')
end

-- release the lua object
self = nil
end

Re: [bamboo] 假删bug

From:
Tang Daogang
Date:
2012-03-24 @ 01:55
已修改。

On Thu, Mar 22, 2012 at 12:02 PM, Uno Young <littlehaker@gmail.com> wrote:

> local fakedelFromRedis = function (self, id)
> local model_key = id and getNameIdPattern2(self, id) or
> getNameIdPattern(self)
> local index_key = getIndexKey(self)
>
> local fields = self.__fields
> -- in redis, delete the associated foreign key-value store
>  for k, v in pairs(self) do
> local fld = fields[k]
> if fld and fld.foreign then
>  local key = model_key + ':' + k
>
> >>>>
>                       db:rename(key, 'DELETED:' + key)
> ==========
> 改为
>       if db:exists(key) then
>         db:rename(key, 'DELETED:' + key)
>       end
> <<<<<<<<
>
> end
>  end
>
> -- rename the key self
> db:rename(model_key, 'DELETED:' + model_key)
>  -- delete the index in the global model index zset
> -- when deleted, the instance's index cache was cleaned.
>  db:zremrangebyscore(index_key, self.id, self.id)
> -- add to deleted collector
>  rdzset.add(dcollector,  model_key)
>
> -- clear fulltext index
>  if isUsingFulltextIndex(self) then
> clearFtIndexesOnDeletion(self)
> end
>  if isUsingRuleIndex(self) then
> updateIndexByRules(self, 'del')
> end
>
> -- release the lua object
> self = nil
> end
>



-- 
Nothing is impossible.