Class LegiScan_Cache_Memory
LegiScan API Memory Cache Class
Basic singleton memory cache that offers a simple non-stateful memory cache or interfaces with an external memcache server, either via Memcache or Memcached.
Underutilized in this application, it currently caches simple exists(ID)
style
lookups. Internally at LegiScan this saves 100-125 qps in production, though in
this isolated API Client implementation will be around 5-10 qps.
$memcache = LegiScan_Cache_Memory::getInstance(); $key = "key-sample-1"; $memcache->set($key, 12345); $value = $memcache->get($key); var_dup($value);
Package: LegiScan\Cache
Copyright: 2010-2020 LegiScan LLC
License: https://opensource.org/licenses/BSD-2-Clause
Author: LegiScan API Team api@legiscan.com
See: LegiScan_Process::checkExists
Link: https://memcached.org/
Link: https://api.legiscan.com/dl/
Located at LegiScan.php
Copyright: 2010-2020 LegiScan LLC
License: https://opensource.org/licenses/BSD-2-Clause
Author: LegiScan API Team api@legiscan.com
See: LegiScan_Process::checkExists
Link: https://memcached.org/
Link: https://api.legiscan.com/dl/
Located at LegiScan.php
private
|
#
__construct( integer $lifetime )
This is not the contructor you are looking for... Static Singleton |
public static
|
#
getInstance( integer $lifetime = self::LIFETIME )
Get a instance of either internal memory cache or external memcached |
public
mixed
|
|
public
|
|
public
boolean
|
integer |
LIFETIME
Default lifetime of API cache objects in seconds (60 minutes) |
#
3600
|
private static
integer
|
$lifetime
Lifetime of cache objects |
|
private static
array
|
$cache
Our cache array if no memcached server |
|
private static
object
|
$instance
Singleton class instance |