2017 © Pedro Peláez
 

library cachesys

image

andrewsauder/cachesys

  • Saturday, March 31, 2018
  • by andrewsauder
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

cacheSys

Simple PHP caching system for raw data or rendered output., (*1)


Installing

Composer is the preferred installation method. https://packagist.org/packages/andrewsauder/cachesys, (*2)

composer require andrewsauder/cachesys

Useage

All of the samples below will assume that you add a use statement inside of your namespace referencing cacheSys., (*3)

<?php
namespace MyVendorNamespace;
use andrewsauder;

If you opt not to add a use statement, you must reference the cacheSys methods by it's fully qualified class name. Ie:, (*4)

\andrewsauder\cacheSys::get( 'cacheName', 'cacheKey' );

Retrieving and Create Cache

This is the core useage of cacheSys. I like to think of it as a wrapper for any complex logic that slows requests down., (*5)

$employee = cacheSys::get( 'employees', 712 );

if( $employee===false ) {
    //do heavy lifting to create $employee
    $employee = 'Andrew';
    cacheSys::put( 'employees', 712, $employee );
}

var_dump( $employee );

Of course, you always need to make sure that your cached data remains relevant. To do this you can make use of the max age parameter of the get method, (*6)

/* get the cached copy of employee 712
 * but return false if the cache was created
 * more than 86,400 seconds (24 hours) ago
 */
$employee = cacheSys::get( 'employees', 712, 86400 );

Delete Cached Item

You can also delete a specific cached item on demand., (*7)

cacheSys::deleteCachedItem( 'employees', 712 );

Delete Cache Category

Or delete an entire cache category. For example, if you wanted to delete all employees instead of just one, you can delete the entire category instead, (*8)

cacheSys::deleteCachedCategory( 'employees');

The Versions

31/03 2018

1.0.0

1.0.0.0

  Sources   Download

28/03 2017

dev-master

9999999-dev https://github.com/andrewsauder/cachesys

Simple PHP caching system for raw data or rendered output.

  Sources   Download

MIT

The Requires

  • php ^5.4 || ^7.0

 

by Andrew Sauder

28/03 2017

1.0.2

1.0.2.0 https://github.com/andrewsauder/cachesys

Simple PHP caching system for raw data or rendered output.

  Sources   Download

MIT

The Requires

  • php ^5.4 || ^7.0

 

by Andrew Sauder

28/03 2017

1.0.1

1.0.1.0 https://github.com/andrewsauder/cachesys

Simple PHP caching system for raw data or rendered output.

  Sources   Download

MIT

The Requires

  • php ^5.4 || ^7.0

 

by Andrew Sauder