madewithlove / illuminate-psr-cache-bridge Goto Github PK
View Code? Open in Web Editor NEWA PSR-6 cache implementation that wraps Laravel's Cache component
License: MIT License
A PSR-6 cache implementation that wraps Laravel's Cache component
License: MIT License
I got this error when fetching an item from cache:
In CacheItemPool.php line 49:
unserialize(): Error at offset 0 of 2 bytes
Looking at the item that was being unserialized here, it was:
Illuminate\Support\Collection^ {#518
#items: []
}
It was not a string. It was already deserialized. So looking into the code, it seems that this package will serialize and unserialize items that go into and come out of the Laravel/Illuminate cache. Laravel will serialize/unserialize data going in and out anyway, so it's done twice. Maybe the older versions of Laravel did not work this way, and this is a leftover.
The reason I believe I got this error, is that I hit a cached item that had been pushed to cache using an Illuminate\Contracts\Cache\Repository
repository - the standard Laravel way - and pulled out using Madewithlove\IlluminatePsrCacheBridge\Laravel\CacheItemPool
. The two store data in the underlying cache that is not compatible - the one stored by this package is serialized twice.
Is this intended? It means cache items can be stored and retreived by either the Laravel cache, or the madewithlove cache, but can never be passed between the two.
Laravel 5.8 now expects the cache lifetime to be supplied in seconds, and not minutes, so the following line will not be correct in Laravel 5.8:
You cache forever rather than for a specific amount of time. This will fill the cache.
We are lucky that this nearly works on php 7.0 and under, because the tests typically don't roll forward into the next second. On php 7.1, microseconds are used, so this test doesn't really test anything.
Just got the following in production:
Exception: DateInterval::__construct(): Unknown or bad format (PTS) in .../vendor/madewithlove/illuminate-psr-cache-bridge/src/Laravel/CacheItem.php:101
Stack trace:
#0 .../vendor/madewithlove/illuminate-psr-cache-bridge/src/Laravel/CacheItem.php(101): DateInterval->__construct('PTS')
#1 .../vendor/php-http/cache-plugin/src/CachePlugin.php(90): Madewithlove\IlluminatePsrCacheBridge\Laravel\CacheItem->expiresAfter(NULL)
#2 .../vendor/php-http/promise/src/FulfilledPromise.php(35): Http\Client\Common\Plugin\CachePlugin->Http\Client\Common\Plugin\{closure}(Object(GuzzleHttp\Psr7\Response))
#3 .../vendor/php-http/cache-plugin/src/CachePlugin.php(95): Http\Promise\FulfilledPromise->then(Object(Closure))
#4 .../vendor/php-http/client-common/src/PluginClient.php(155): Http\Client\Common\Plugin\CachePlugin-
I've not looked into this yet to determine if the other library is calling this one incorrectly, or if there's a bug here. Just giving you an early heads up.
I believe the code in the ServiceProvider should be bind()
, not share()
.
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.