You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bayes_cache_check.lua 542B

1234567891011121314151617181920
  1. -- Lua script to perform cache checking for bayes classification
  2. -- This script accepts the following parameters:
  3. -- key1 - cache id
  4. -- key2 - configuration table in message pack
  5. local cache_id = KEYS[1]
  6. local conf = cmsgpack.unpack(KEYS[2])
  7. cache_id = string.sub(cache_id, 1, conf.cache_elt_len)
  8. -- Try each prefix that is in Redis
  9. for i = 0, conf.cache_max_keys do
  10. local prefix = conf.cache_prefix .. string.rep("X", i)
  11. local have = redis.call('HGET', prefix, cache_id)
  12. if have then
  13. return tonumber(have)
  14. end
  15. end
  16. return nil