yiisoft / cache-file Goto Github PK
View Code? Open in Web Editor NEWYii Cache Library - File Handler
Home Page: https://www.yiiframework.com/
License: BSD 3-Clause "New" or "Revised" License
Yii Cache Library - File Handler
Home Page: https://www.yiiframework.com/
License: BSD 3-Clause "New" or "Revised" License
->withDirectoryMode(0777)
->withDirectoryLevel(0);
directory created with 0777
directory created with default 0775
Q | A |
---|---|
Version | 2.0.0 |
PHP version | 8.1 |
Operating system | Linux Mint 20.3 |
Because of createDirectoryIfNotExists()
in FileCache
constructor building object with other than default directory mode will be ignored
This method deprecated and must to removed in next major release.
Remove travis if it exists
psr/simple-cache
to ^2.0|^3.0
.^8.0
and make improvements related to this.I have saw this line: https://github.com/yiisoft/cache-file/blob/master/src/FileCache.php#L163 Would you think this is safe way to store TTL? What about store one as first line in the file and use next lines as cached value like this:
use SplFileObject;
use function serialize;
use function time;
use const LOCK_EX;
use const LOCK_UN;
use const PHP_EOL;
$file = new SplFileObject('/path/to/cache/file.bin', 'c+')
$file->flock(LOCK_EX);
$file->rewind();
$file->ftruncate(0);
$file->fwrite((string)(time() + 3600)); // TTL 1 hour
$file->fwrite(PHP_EOL);
$file->fwrite((string)serialize($value)); // cached value
$file->fflush();
$file->flock(LOCK_UN);
It's just a question because I had tried to find out whether can I use future time for time of creating of the file and didn't find any strong answer. But I think that time of creating should be time of creating and no more.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.