jonswar/perl-chi — Issue #4: I want to make a patch for CHI - please approve my ideas before :-)
Author: Perlover
Created: 2011-11-02 18:29:34+00:00
State: open

Good day!

Thanks for useful module!

But i need now in some feature, i can make it myself but before i decide to ask you for approving because i want to see it feature in next releases of CHI ;-)

Idea is a following:

I want to make a feature as Unix make command has. It feature is needed as i think. For example multi-page breaking of each page will depend from whole piece of data for all pages. And if i will cache this whole data piece and define compute methos for it, i will want to recompute every page if this main whole data piece was changed (page's compute will only make like splice method for it of whole piece)
For it i want to add a new features to $cache->compute method:

1) Every key of compute can be used as 'target' like make. target name == $key of compute
2) Every target will be like trigger with his timestamp (like empty ). Targets will be kept in other namespace with same key as compute and they will may be as flat numbers of time() or Time::HiRes::time()
3) Every compute can have some dependences ('prerequisite' term of make)
4) CHI if does 'compute' method which has a certain options for it (i am thinking about API now) will look in dependences and if current object in cache is not expired but if target ($key) older than target(s) of dependence(s) - it will recompute $code and after will refresh target's trigger time. Of cause it should look up dependeces of dependences recursively for it (every time of compute method). But target triggers will be very small and i think it will not decrease performance dramatically. I know about expire_if option of get but implementation of this idea for it very cumbersome.

Please tell me your opinion of this

Thanks!

// Perlover :-)