Code Monkey home page Code Monkey logo

Comments (6)

jhallbachner avatar jhallbachner commented on August 16, 2024

"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.

lstrojny avatar lstrojny commented on August 16, 2024

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.

jhallbachner avatar jhallbachner commented on August 16, 2024

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.

tedivm avatar tedivm commented on August 16, 2024

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.

 avatar commented on August 16, 2024

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.

CMCDragonkai avatar CMCDragonkai commented on August 16, 2024

These strategies should be worked into PSR-6!

from stash.

Related Issues (20)

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.