add md5:update and md5:sum methods

This commit is contained in:
chrox
2015-02-19 22:12:11 +08:00
parent efe8e65dd9
commit 07ff30f89c
3 changed files with 29 additions and 11 deletions

View File

@@ -122,7 +122,7 @@ function Cache:check(key, ItemClass)
end
return self.cache[key]
elseif ItemClass then
local cached = self.cached[md5(key)]
local cached = self.cached[md5:sum(key)]
if cached then
local item = ItemClass:new{}
local ok, msg = pcall(item.load, item, cached)
@@ -159,7 +159,7 @@ function Cache:serialize()
-- only dump cache item that requests serialization explicitly
if cache_item.persistent and cache_item.dump then
DEBUG("dump cache item", key)
cache_size = cache_item:dump(cache_path..md5(key)) or 0
cache_size = cache_item:dump(cache_path..md5:sum(key)) or 0
if cache_size > 0 then break end
end
end