Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why cache could be optional #11

Closed
garex opened this issue Oct 14, 2016 · 3 comments
Closed

Why cache could be optional #11

garex opened this issue Oct 14, 2016 · 3 comments

Comments

@garex
Copy link

garex commented Oct 14, 2016

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.

@michaelcullum
Copy link
Member

Did you mean to add this to #10?

@garex
Copy link
Author

garex commented Oct 14, 2016

And to #9 also.

@garex
Copy link
Author

garex commented Oct 17, 2016

PSR-6 recommendation states:

While caching is often an important part of application performance, it should never be a critical part of application functionality.

This is another +1 to why cache is an optional dependecy.

@Crell Crell closed this as completed Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants