Skip to content
PHP File Cache, use Separate Chaining resolve hash conflict. one cache, one file, one bucket.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.editorconfig
.gitattributes
.gitignore
.scrutinizer.yml
.styleci.yml
.travis.yml
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
ISSUE_TEMPLATE.md
LICENSE.md
PULL_REQUEST_TEMPLATE.md
README.md
composer.json
phpcs.xml.dist
phpunit.xml.dist

README.md

file-cache

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

PHP File Cache, use Separate Chaining resolve hash conflict. one cache, one file, one bucket.

Feature

  • Cache can set expired time.
  • Use Separate Chaining resolve hash conflict.
  • Hash key is the path to store data.

Structure

If any of the following are applicable to your project, then the directory structure should follow industry best practices by being named the following.

src/
tests/
vendor/

Install

Via Composer

$ composer require yiranzai/file-cache

Usage

API

This package provides these methods.

  • put($key, $data, $minutes): Cache put one cache to file,set expired time
  • forever($key, $data): Cache forever save one cache to file
  • get($key, $default = null): ?string get the data corresponding to the key
  • delete($key): bool delete one cache
  • flush(): void delete all cache
  • dataPath($path): self change data save path

Demo

$cache = new Yiranzai\File\Cache();

$cache->put('key', 'data', 10);
$cache->put('key1', 'data1', new DateTime());
$cache->put('key2', 'data2', 'now');
$cache->forever('key3', 'data3');

$cache->get('key');   // data

$cache->delete('key');   // true

$cache->flush();

$cache->get('not_exists','nothing');   // nothing
$cache->dataPath('YOUR_PATH');

// or

$cache = new Yiranzai\File\Cache(['dataPath'=>'YOUR_PATH']);

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email wuqingdzx@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

You can’t perform that action at this time.