Cache tools for PHP applications
Find a file
2023-08-13 12:04:26 +03:00
src add callback methods support, update keys format 2023-08-10 15:31:31 +03:00
.gitignore initial commit 2023-08-09 20:12:41 +03:00
composer.json initial commit 2023-08-09 20:12:41 +03:00
LICENSE Initial commit 2023-08-09 19:26:01 +03:00
README.md update readme 2023-08-13 12:04:26 +03:00

cache-php

Cache tools for PHP applications

Memory

Extends PHP memcached

Init

$memory = new Yggverse\Cache\Memory(

  'localhost, // memcached server host, localhost by default
  11211,      // memcached server port, 11211 by default

  'my_app',   // application namespace
  3600        // cache time offset by default
);

Supported methods

Memory::set
Memory::delete
Memory::flush
Memory::get
Memory::getByValueCallback

Return cached or cache new value of plain value callback

  $value = $memory->getByValueCallback(
    'key_name', // string, unique key name
    'value',    // mixed, plain value
    3600,       // optional, cache timeout offset for this value
  );
Memory::getByMethodCallback

Return cached or cache new value of object method callback

  $value = $memory->getByMethodCallback(
    $class_object,         // object of method class
    'method_name',         // object method name
    [
      $method_attribute_1, // optional, array of attributes callback method requires
      $method_attribute_2,
      ...
    ]
    3600,                  // optional, cache timeout offset for this value
  );