Giter Club home page Giter Club logo

cache-util's People

Contributors

bshaffer avatar crell avatar ffleigegrz avatar kynx avatar michaelcullum avatar namenu avatar ostrolucky avatar ralflang avatar santyagoseaman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cache-util's Issues

Add Boilerplate Exceptions

It would be great to add boilerplate implementations of Psr\Cache\Exception and Psr\Cache\InvalidArgumentException to this library.

php 5.4 compatibility issue with DateTimeInterface

  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

Why cache could be optional

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.