request_with_cache.php 587 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jaeger <JaegerCode@gmail.com>
  5. * Date: 18/12/11
  6. * Time: 下午6:48
  7. */
  8. require __DIR__.'/../vendor/autoload.php';
  9. use Jaeger\GHttp;
  10. use Cache\Adapter\Predis\PredisCachePool;
  11. $rt = GHttp::get('http://httpbin.org/get',[
  12. 'wd' => 'QueryList'
  13. ],[
  14. 'cache' => __DIR__,
  15. 'cache_ttl' => 120
  16. ]);
  17. print_r($rt);
  18. $client = new \Predis\Client('tcp:/127.0.0.1:6379');
  19. $pool = new PredisCachePool($client);
  20. $rt = GHttp::get('http://httpbin.org/get',[
  21. 'wd' => 'QueryList'
  22. ],[
  23. 'cache' => $pool,
  24. 'cache_ttl' => 120
  25. ]);
  26. print_r($rt);