Skip to content

Instantly share code, notes, and snippets.

@silverslice
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silverslice/9b0a0ad555f073330be2 to your computer and use it in GitHub Desktop.
Save silverslice/9b0a0ad555f073330be2 to your computer and use it in GitHub Desktop.
Bluz file cache test code
<?php
// Environment
define('DEBUG', false);
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
// Paths
define('PATH_ROOT', realpath(dirname(__FILE__). '/../'));
define('PATH_APPLICATION', PATH_ROOT . '/cachetest');
define('PATH_VENDOR', PATH_ROOT . '/vendor');
// init autoloader
require_once PATH_ROOT . '/vendor/autoload.php';
use Bluz\Cache\Cache;
$settings = [
"adapter" => "phpFile",
"settings" => [
"phpFile" => [
"cacheDir" => PATH_APPLICATION .'/cache'
]
]
];
$cache = new Cache();
$cache->setOptions($settings);
$val = file_get_contents('content.txt'); // ~100KB
$key = 'test-237';
$res = $cache->get($key);
if (!$res) {
$cache->set($key, $val, 3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment