init without trunk
This commit is contained in:
parent
ed24ac4994
commit
bb809e7233
14652 changed files with 177862 additions and 94817 deletions
1
vendor/gregwar/cache/Gregwar/Cache/demo/.gitignore
vendored
Normal file
1
vendor/gregwar/cache/Gregwar/Cache/demo/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
cache/
|
||||
14
vendor/gregwar/cache/Gregwar/Cache/demo/garbage.php
vendored
Normal file
14
vendor/gregwar/cache/Gregwar/Cache/demo/garbage.php
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
include('../autoload.php'); // If using composer
|
||||
|
||||
use Gregwar\Cache\GarbageCollect;
|
||||
|
||||
if (!is_dir('cache')) {
|
||||
`mkdir cache`;
|
||||
}
|
||||
`touch -t 9901010101 cache/foo`;
|
||||
`touch cache/bar`;
|
||||
|
||||
GarbageCollect::dropOldFiles(__DIR__.'/cache', 30, true);
|
||||
|
||||
23
vendor/gregwar/cache/Gregwar/Cache/demo/max-age.php
vendored
Normal file
23
vendor/gregwar/cache/Gregwar/Cache/demo/max-age.php
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
include('../autoload.php');
|
||||
|
||||
$cache = new Gregwar\Cache\Cache;
|
||||
|
||||
$data = $cache->getOrCreate('uppercase.txt', array('max-age' => 2), function() {
|
||||
echo "First call: generating file...\n";
|
||||
return strtoupper(file_get_contents('original.txt'));
|
||||
});
|
||||
|
||||
$data = $cache->getOrCreate('uppercase.txt', array('max-age' => 2), function() {
|
||||
echo "Second call: generating file, this should not happen!...\n";
|
||||
return strtoupper(file_get_contents('original.txt'));
|
||||
});
|
||||
|
||||
echo "Waiting 4s...\n";
|
||||
sleep(4);
|
||||
|
||||
$data = $cache->getOrCreate('uppercase.txt', array('max-age' => 2), function() {
|
||||
echo "Third call: generating cache file, because it expired...\n";
|
||||
return strtoupper(file_get_contents('original.txt'));
|
||||
});
|
||||
4
vendor/gregwar/cache/Gregwar/Cache/demo/original.txt
vendored
Normal file
4
vendor/gregwar/cache/Gregwar/Cache/demo/original.txt
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
There he goes.
|
||||
One of God's own prototypes.
|
||||
A high-powered mutant of some kind never even considered for mass production.
|
||||
Too weird to live, and too rare to die.
|
||||
20
vendor/gregwar/cache/Gregwar/Cache/demo/red-file.php
vendored
Normal file
20
vendor/gregwar/cache/Gregwar/Cache/demo/red-file.php
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
include('../autoload.php'); // If using composer
|
||||
|
||||
use Gregwar\Cache\Cache;
|
||||
|
||||
$cache = new Cache;
|
||||
$cache->setCacheDirectory('cache'); // This is the default
|
||||
|
||||
// If the cache exists, this will return it, else, the closure will be called
|
||||
// to create this image
|
||||
$file = $cache->getOrCreateFile('red-square.png', array(), function($filename) {
|
||||
$i = imagecreatetruecolor(100, 100);
|
||||
imagefill($i, 0, 0, 0xff0000);
|
||||
file_put_contents($filename, 'abc');
|
||||
imagepng($i, 'a.png');
|
||||
imagepng($i, $filename);
|
||||
});
|
||||
|
||||
echo $file, "\n";
|
||||
20
vendor/gregwar/cache/Gregwar/Cache/demo/red.php
vendored
Normal file
20
vendor/gregwar/cache/Gregwar/Cache/demo/red.php
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
include('../autoload.php'); // If using composer
|
||||
|
||||
use Gregwar\Cache\Cache;
|
||||
|
||||
$cache = new Cache;
|
||||
$cache->setCacheDirectory('cache'); // This is the default
|
||||
|
||||
// If the cache exists, this will return it, else, the closure will be called
|
||||
// to create this image
|
||||
$data = $cache->getOrCreate('red-square.png', array(), function($filename) {
|
||||
$i = imagecreatetruecolor(100, 100);
|
||||
imagefill($i, 0, 0, 0xff0000);
|
||||
file_put_contents($filename, 'abc');
|
||||
imagepng($i, $filename);
|
||||
});
|
||||
|
||||
header('Content-type: image/png');
|
||||
echo $data;
|
||||
14
vendor/gregwar/cache/Gregwar/Cache/demo/uppercase.php
vendored
Normal file
14
vendor/gregwar/cache/Gregwar/Cache/demo/uppercase.php
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
include('../autoload.php');
|
||||
|
||||
use Gregwar\Cache\Cache;
|
||||
|
||||
$cache = new Cache;
|
||||
|
||||
$data = $cache->getOrCreate('uppercase.txt', array('younger-than' => 'original.txt'), function() {
|
||||
echo "Generating file...\n";
|
||||
return strtoupper(file_get_contents('original.txt'));
|
||||
});
|
||||
|
||||
echo $data;
|
||||
Loading…
Add table
Add a link
Reference in a new issue