Overview

Packages

  • LegiScan
    • API
    • Cache
    • Common
    • Exceptions
    • Utility
  • PHP

Classes

  • LegiScan_Cache_File
  • LegiScan_Cache_Memory
  • Overview
  • Package
  • Class

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
Methods summary
private
# __construct( integer $lifetime )

This is not the contructor you are looking for... Static Singleton

This is not the contructor you are looking for... Static Singleton

Parameters

$lifetime
Time in seconds for api cache lifetime
public static
# getInstance( integer $lifetime = self::LIFETIME )

Get a instance of either internal memory cache or external memcached

Get a instance of either internal memory cache or external memcached

Parameters

$lifetime
Lifetime of a cached value
public mixed
# get( string $key )

Get an entry from the cache

Get an entry from the cache

Parameters

$key
Cache key to retrieve

Returns

mixed
The contents of the file or FALSE for missing/stale
public
# set( string $key, string $data, string $lifetime = self::LIFETIME )

Store an entry in the cache

Store an entry in the cache

Parameters

$key
Cache key value
$data
Data to store under cache key
$lifetime
How long until the data expires, in seconds
public boolean
# flush( )

Clear all items from cache

Clear all items from cache

Returns

boolean
Indicating the success/failure of the cleanup
Constants summary
integer LIFETIME

Default lifetime of API cache objects in seconds (60 minutes)

Default lifetime of API cache objects in seconds (60 minutes)

# 3600
Properties summary
private static integer $lifetime

Lifetime of cache objects

Lifetime of cache objects

#
private static array $cache

Our cache array if no memcached server

Our cache array if no memcached server

#
private static object $instance

Singleton class instance

Singleton class instance

#
LegiScan API Client API documentation generated by ApiGen