Skip to content

Commit a25e40a

Browse files
authored
Update psr/cache requirment to include v2 and v3
Also updates the cache implementation used in the example file because tedvium/stash doesn't yet support the new versions of psr/cacche. Fix a bug with the cache example which was using the 'test' API call, which declares itself as 'nocache'. Instead, call it manually (with the default of nocache=false). Refs #55
1 parent 4744297 commit a25e40a

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
"ext-libxml": "*",
2121
"ext-simplexml": "*",
2222
"carlos-mg89/oauth": "^0.8",
23-
"psr/cache": "^1.0"
23+
"psr/cache": "^1.0|^2.0|^3.0"
2424
},
2525
"require-dev": {
2626
"squizlabs/php_codesniffer": "^3.0",
2727
"mediawiki/minus-x": "^0.3 || ^1.0",
2828
"phpunit/phpunit": "^9.5",
29-
"tedivm/stash": "^0.17.1",
29+
"symfony/cache": "^5.4",
3030
"php-parallel-lint/php-parallel-lint": "^1.3",
3131
"phan/phan": "^5.4"
3232
},

examples/caching.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
// Make sure we have the required configuration values.
1111
$configFile = __DIR__ . '/config.php';
1212
require_once $configFile;
13-
if (empty($apiKey) || empty($apiSecret) || empty($accessToken) || empty($accessTokenSecret)) {
14-
echo 'Please set $apiKey, $apiSecret, $accessToken, and $accessTokenSecret in ' . $configFile;
13+
if (empty($apiKey) || empty($apiSecret)) {
14+
echo 'Please set $apiKey and $apiSecret in ' . $configFile;
1515
exit(1);
1616
}
1717

@@ -22,9 +22,8 @@
2222
sendRequests($flickr);
2323

2424
// Now add a cache.
25-
$driver = new Stash\Driver\FileSystem([ 'path' => __DIR__ . '/cache' ]);
26-
$pool = new Stash\Pool($driver);
27-
$flickr->setCache($pool);
25+
$cache = new Symfony\Component\Cache\Adapter\FilesystemAdapter('PhpFlickr', 0, __DIR__ . '/cache/');
26+
$flickr->setCache($cache);
2827

2928
// Now send the same requests, and the second of them should be much faster.
3029
echo "With caching:\n";
@@ -38,7 +37,7 @@ function sendRequests(\Samwilson\PhpFlickr\PhpFlickr $flickr)
3837
{
3938
for ($i = 1; $i <= 3; $i++) {
4039
$start = microtime(true);
41-
$flickr->test_echo([]);
40+
$flickr->request('flickr.test.echo');
4241
echo " $i. " . number_format(microtime(true) - $start, 3) . "\n";
4342
}
4443
}

0 commit comments

Comments
 (0)