chrisullyott/simple-cache

Quick and easy data caching in the filesystem.

v1.2.0 2020-10-23 18:33 UTC

This package is auto-updated.

Last update: 2024-04-24 02:23:44 UTC


README

Quick and easy data caching in the filesystem.

Install

$ composer require chrisullyott/simple-cache

Instantiate

require 'vendor/autoload.php';

use ChrisUllyott\Cache;
$cache = new Cache('cache_id');

Setting data

$cache->set("Some data");

Getting data

echo $cache->get(); // "Some data"

Clearing

$cache->clear();

Usage

<?php

require 'vendor/autoload.php';

use ChrisUllyott\Cache;
$cache = new Cache('my_key');

$data = $cache->get();

if (!$data) {
    $data = my_api_request();
    $cache->set($data);
}

print_r($data);

Testing

$ ./vendor/bin/phpunit --configuration=./tests/phpunit.xml