php-fig / cache-util Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
It was suggested to me to move this php-fig/cache#16 here, but not sure where to put in this codebase
It would be great to add boilerplate implementations of Psr\Cache\Exception
and Psr\Cache\InvalidArgumentException
to this library.
41 - it may use psr6 compliant cache
warning: assert(): Assertion "$expiration instanceof \DateTimeInterface" failed in
/home/bartosz/PhpstormProjects/portal_customer/vendor/fig/cache-util/src/BasicCacheItemTrait.php line 75
0 vendor/phpspec/phpspec/src/PhpSpec/Runner/Maintainer/ErrorMaintainer.php:121
throw new PhpSpec\Exception\Example\ErrorException("warning: assert(): Assert...")
1 vendor/fig/cache-util/src/BasicCacheItemTrait.php:75
assert("$expiration instanceof \D...")
2 src/CustomerPortalAdminClient/CustomerPortalAdminClient.php:59
Fig\Cache\Memory\MemoryCacheItem->expiresAt([obj:DateTime])
assert checks if argument is an instance of \DateTimeInterface which has been added in php 5.5 which in turn causes warning on php5.4.
http://php.net/manual/en/class.datetimeinterface.php
Examples:
Same as https://github.com/php-fig/log/blob/master/Psr/Log/NullLogger.php
Cache as an optional injectable dependency. When class user not provides it -- we take ready NullPool and use it.
As I understand, psr/cache dont' want to accept the idea of cache optionality. I will try to explain why optinality is a good idea.
Ok, let's talk about MySQL server.
As far as I'm concerned, MySQL server is good example of proper design.
According to this article you may see that cache is optional. It doesn't matter whereas user enabled it or not. The result of the query will be the same in any case.
It means that null-cache is a good idea.
From user's point of view the cache is not always needed. It's an optimization, infrastructure layer tool. When we design system -- we dont' start from optimization, we start from domain logic and then after some time, when we find bottlenecks, we optimize 'em. So from scratch we allow class's user to use it without any cache-setup issues out of the box. It's a friendly design. Same as we see in great PSR/Log.
Testability of objects with injected cache is an issue. What it should take? Some real pre-cleaned cache pool or home-grown null implementation?
The main advantage of null object implementation is that it's behaviour is do nothing
. In case of cache pool it's just never hit/get/save
behaviour. There is one way to do it.
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.