PHPSocialNetwork / phpfastcache

A high-performance backend cache system. It is intended for use in speeding up dynamic web applications by alleviating database load. Well implemented, it can drops the database load to almost nothing, yielding faster page load times for users, better resource utilization. It is simple yet powerful.
https://www.phpfastcache.com
MIT License
2.38k stars 451 forks source link

Set a path for cache files for v8 #850

Closed Pok4 closed 2 years ago

Pok4 commented 2 years ago

Hi, guys :)

I'm use this one. I have a question... How to set a path for cache directory ? Now, my configuration is this:

//PHP Fast Cache
use Phpfastcache\Helper\Psr16Adapter;
$cacher = new Psr16Adapter((getenv('CACHE_TYPE')== false) ? 'files' : getenv('CACHE_TYPE'));

please, tell me how to set a path for cache files, because i don't know where is stored now. I want to be DIR.'/cache';

github-actions[bot] commented 2 years ago

Hello curious contributor ! Since it seems to be your first contribution, make sure that you've been:

Geolim4 commented 2 years ago

Hello,

Please read the Wiki: https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV4%CB%96%5D-Configuration-Options

And use the ConfigurationOption class of generic options or the Files\Config class for specific options.

Also take a look at our tests here: https://github.com/PHPSocialNetwork/phpfastcache/blob/bcd068ff1a78cd1475a4d8c13ed371711465ef40/tests/ReadWriteOperations.test.php#L48

Cheers, Georges

Pok4 commented 2 years ago

Ok, now i made the code to look like this:

//PHP Fast Cache
use Phpfastcache\Helper\Psr16Adapter;
use Phpfastcache\Drivers\Files\Config as FilesConfig;
$cacher = new Psr16Adapter((getenv('CACHE_TYPE')== false) ? 'files' : getenv('CACHE_TYPE'),

new FilesConfig([
  'path' => __DIR__.'/cache',
  'secureFileManipulation' => true,
  'securityKey' => '_phpfastcache_',
]));

and everything is working :) thank you!

Geolim4 commented 2 years ago

Ok, now i made the code to look like this:

//PHP Fast Cache
use Phpfastcache\Helper\Psr16Adapter;
use Phpfastcache\Drivers\Files\Config as FilesConfig;
$cacher = new Psr16Adapter((getenv('CACHE_TYPE')== false) ? 'files' : getenv('CACHE_TYPE'),

new FilesConfig([
  'path' => __DIR__.'/cache',
  'secureFileManipulation' => true,
  'securityKey' => '_phpfastcache_',
]));

and everything is working :) thank you!

Jusr don't forget to pass the new FilesConfig object as the second argument of new Psr16Adapter( (watch the class signature on your IDE)