Comments (6)
"Driver" in this context is the equivalent of what we're currently calling "sub-handlers," yes? I like the idea of a nomenclature change here just to make clearer the difference between the two, and to standardize an approach to driver choice.
Also, regardless of the exact architecture in terms of invocation, I like the idea of moving from the current MultiHandler model to one where all Cache objects utilize a composite handler system of some kind.
Re: Invocation Strategies, why not just inject strategies on the handler level? Attaching decision objects (that provide tests on factors like data size, ttl length, etc.) to each handler could allow us to create complex caching behaviors where necessary but still default to the current stacked behavior (store everywhere, retrieve from first available) without any such input.
from stash.
Driver
is indeed the successor of Sub-Handler. There wouldn’t be a uniform interface for them so they can be tightly coupled with the using Handler to be as thin as possible.
The whole Composite/Collection/Invoker layer can be used at will anyway, as CompositeHandler
implements the same interface as all the other handlers. So the default behavior could be what we have today.
Re: Strategies on a Handler level. When injecting strategies to handlers directly, they would not know about the other available handlers currently configured so fallback, write-to-all, read-from-first etc. would not be possible.
from stash.
As long as handlers have an ordering, couldn't you implement each of these patterns using a combination of strategies for each, if the CompositeHandler polls each Handler and writes to it if it passes the tests?
Implementing a specific Strategy decoration layer would eliminate the need to maintain an ordering of handlers in the CompositeHandler (since an OrderingStrategy or something would do so instead) but I'm concerned that implementing strategies that apply to all Handlers at once would be less flexible than simple injected logic in each handler.
from stash.
I'm pretty much committed to the use cases you provided, as they make a ton of sense. I like where you're going with things too (ask Josh, the way to win me over on anything is with a good chart- i'd love to know what you used to make that one).
One thing I want to stress is that performance is a huge priority for this project. One of the reasons I've resisted some levels of complexity in the handlers themselves was to ensure they were as quick as possible. The reason I bring it up is that the decoration layer, as Josh calls it, seems like it would be fairly unobtrusive. The extra code would only be called if someone explicitly added the rules in place and in most cases store never happen, since the stuff is already cached. I also feel like this could be made extremely powerful without a significant amount of complexity.
Putting that aside for a second, I'd like to hear a bit more about how this would work- particularly the InvokerStrategy class. I think an example class (a simple one, doesn't have to work or anything) would really help. There are a few other minor question- It seems like the CompositeHandler is simply a more powerful version of the MultiHandler (with a much better name)- I'm a roughly correct in that assumption? Also, is there a benefit to using the ArrayCollection class (which we'd have to pull from Doctrine I believe?) over just an array?
from stash.
One added performance gain: delayed set.. in the context of a web request, there really is little reason to immediately try to save a cached object to backend storage[memcache, apc, file, etc]. Instead use ephermal for all storage, and use the destructor events for the other backends to push the data out. In theory, destructors will be called after the web page data has been flushed to the end user - so you avoid the performance lag of multiple cache save events while still saving the data.
from stash.
These strategies should be worked into PSR-6!
from stash.
Related Issues (20)
- Driver Memcache "clear" = "inc" ? HOT 2
- Warning from filesystem driver: mkdir(): File exists in /data/www/wrbm/corporate/prod/vendor/tedivm/stash/src/Stash/Driver/FileSystem.php on line 234 HOT 5
- Stash Issue with Concrete5? HOT 4
- lock method creates empty folder
- class_exists() calls in APC class may trigger fatal errors
- Cached instances of objects can be altered outside of Stash HOT 3
- Redis items aren't really deleted? HOT 1
- How to disable stashcache throughout project HOT 1
- Filedriver cannot save the cache with expiration time of less than 40 seconds HOT 1
- Filedriver purge didn't work in docker HOT 2
- Function Redis::delete() is deprecated HOT 4
- Password is not global entity, it should be available in each servers for redis
- PHP 8.0 support HOT 1
- Enhance PHP 8 compatibility HOT 2
- SQLite PDO driver does not honor file permissions HOT 1
- [Redis] Option to authenticate using name and password HOT 1
- Union type declaration in Session.php is available as of PHP 8.0.0 HOT 1
- Query wildcard syntax? HOT 1
- Add an ability to disable expiration time randomization. HOT 2
- Update psr/cache to v3.0.0 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stash.