docs/api/source-system.library.cache.memcached.html
| 1: | <?php | | 2: | namespace Opencart\System\Library\Cache; | | 3: | /** | | 4: | * Class Memcached | | 5: | * | | 6: | * @package Opencart\System\Library\Cache | | 7: | */ | | 8: | class Memcached { | | 9: | /** | | 10: | * @var \Memcached | | 11: | */ | | 12: | private \Memcached $memcached; | | 13: | /** | | 14: | * @var int | | 15: | */ | | 16: | private int $expire; | | 17: | | | 18: | public const CACHEDUMP_LIMIT = 9999; | | 19: | | | 20: | /** | | 21: | * Constructor | | 22: | * | | 23: | * @param int $expire | | 24: | */ | | 25: | public function __construct(int $expire = 3600) { | | 26: | $this->expire = $expire; | | 27: | | | 28: | $this->memcached = new \Memcached(); | | 29: | $this->memcached->addServer(CACHE_HOSTNAME, CACHE_PORT); | | 30: | } | | 31: | | | 32: | /** | | 33: | * Get | | 34: | * | | 35: | * @param string $key | | 36: | * | | 37: | * @return mixed | | 38: | */ | | 39: | public function get(string $key) { | | 40: | return $this->memcached->get(CACHE_PREFIX . $key); | | 41: | } | | 42: | | | 43: | /** | | 44: | * Set | | 45: | * | | 46: | * @param string $key | | 47: | * @param mixed $value | | 48: | * @param int $expire | | 49: | * | | 50: | * @return void | | 51: | */ | | 52: | public function set(string $key, $value, int $expire = 0): void { | | 53: | if (!$expire) { | | 54: | $expire = $this->expire; | | 55: | } | | 56: | | | 57: | $this->memcached->set(CACHE_PREFIX . $key, $value, $expire); | | 58: | } | | 59: | | | 60: | /** | | 61: | * Delete | | 62: | * | | 63: | * @param string $key | | 64: | * | | 65: | * @return void | | 66: | */ | | 67: | public function delete(string $key): void { | | 68: | $this->memcached->delete(CACHE_PREFIX . $key); | | 69: | } | | 70: | } | | 71: | |
OpenCart API API documentation generated by ApiGen dev-master