Base.php 855 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * @todo
  4. * - Improve lua scripts by using SCAN family commands
  5. * - Deambiguate why we need the namespace only for flush*() operations
  6. * - Implement the isEmpty() method by using SCAN or KEYS
  7. */
  8. abstract class Redis_Cache_Base extends Redis_AbstractBackend
  9. {
  10. /**
  11. * Lastest cache flush KEY name
  12. */
  13. const LAST_FLUSH_KEY = '_last_flush';
  14. /**
  15. * Delete by prefix lua script
  16. */
  17. const EVAL_DELETE_PREFIX = <<<EOT
  18. local keys = redis.call("KEYS", ARGV[1])
  19. for i, k in ipairs(keys) do
  20. redis.call("DEL", k)
  21. end
  22. return 1
  23. EOT;
  24. /**
  25. * Delete volatile by prefix lua script
  26. */
  27. const EVAL_DELETE_VOLATILE = <<<EOT
  28. local keys = redis.call('KEYS', ARGV[1])
  29. for i, k in ipairs(keys) do
  30. if "1" == redis.call("HGET", k, "volatile") then
  31. redis.call("DEL", k)
  32. end
  33. end
  34. return 1
  35. EOT;
  36. }