TaoLer/vendor/jaeger/g-http/examples/request_with_cache.php

33 lines
587 B
PHP
Raw Normal View History

2022-11-18 10:31:44 +08:00
<?php
/**
* Created by PhpStorm.
* User: Jaeger <JaegerCode@gmail.com>
* Date: 18/12/11
* Time: 下午6:48
*/
require __DIR__.'/../vendor/autoload.php';
use Jaeger\GHttp;
use Cache\Adapter\Predis\PredisCachePool;
$rt = GHttp::get('http://httpbin.org/get',[
'wd' => 'QueryList'
],[
'cache' => __DIR__,
'cache_ttl' => 120
]);
print_r($rt);
$client = new \Predis\Client('tcp:/127.0.0.1:6379');
$pool = new PredisCachePool($client);
$rt = GHttp::get('http://httpbin.org/get',[
'wd' => 'QueryList'
],[
'cache' => $pool,
'cache_ttl' => 120
]);
print_r($rt);