The web based syslog https://lggr.io
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.

47 lines
1004B

  1. <?php
  2. class LggrCacheRedis extends AbstractLggrCache {
  3. // 5 minutes
  4. const MAXAGE = 300;
  5. const REDISHOST = 'localhost';
  6. const REDISDB = 0;
  7. const REDISPFX = 'lggr_';
  8. private $r = null;
  9. function __construct() {
  10. $this->r = new Redis();
  11. $this->r->connect(self::REDISHOST);
  12. $this->r->select(self::REDISDB);
  13. }
  14. // constructor
  15. function __destruct() {
  16. $this->r->close();
  17. }
  18. // destructor
  19. public function store($key, $value) {
  20. $s = serialize($value);
  21. $this->r->setex(SELF::REDISPFX . $key, self::MAXAGE, $s);
  22. }
  23. // function
  24. public function retrieve($key) {
  25. $value = $this->r->get(SELF::REDISPFX . $key);
  26. if (false === $value) {
  27. return null;
  28. }
  29. return unserialize($value);
  30. }
  31. // function
  32. public function purge($key) {
  33. $this->r->delete(SELF::REDISPFX . $key);
  34. } // function
  35. } // class
Social stuff:
Mastodon