Closed peter-mw closed 10 years ago
What do you need to do this for? Why do you need to overload those methods? Give me a little more information so I can try to recommend a way of doing it.
I have put Idiorm adapter in my CMS yesterday https://github.com/microweber/microweber/blob/new/src/Microweber/Adapters/Orm/IdiOrm.php
Now i want to migrate all my queries to Idiorm and ditch the old ugly DB functions.
The problem is that i have internal cache system i want to use. The CMS is query heavy and relies on cache (Files, APC or memcache)
I need a way to swap the idiorm cache functions.
I need to cache the data on _execute
and clear the cache on save
Maybe adding a configure
option will be the best way to use custom functions
Do you want me to try to implement this?
I will try the following idea - to pass
ORM::configure('cache_hash_callback', function($my_class){ });
ORM::configure('cache_save_callback', function($my_class){ });
ORM::configure('cache_delete_callback', function($my_class){ });
and somehow work this out in Idirom class
I badly need external caching mechanism
So in this case why don't you just cache the result in your adapter rather than in Idiorm directly?
Hi, this is test adapter and just made it to see if i can hack the table prefix
I don't want to override the functions by extending them and breaking the compatibility with the ORM
class. If i use my adapter approach i will be able to cache the result, but have no ability to clean the cache, because i don't know when the save
function is executed
On the other hand: I want to integrate Paris too, in this case i would like to use caching there though idiom Paris fits very nice and though it i will be able to overcome my table prefix problem, but still have the caching problem.
If we can put a cache callback functions though ORM::configure
this will be the cleanest approach and also work on multiple connections
I am really not so sure about this as caching is not really a core concern of Idiorm itself. On the other hand it does seem logical that as we do have caching that it should be more controllable.
If you do decide to implement this then to ensure it gets included please remember to include documentation and tests in your pull request. Please remember to update the changelog in the readme too.
Hi, I will try to integrate this in the next days. Will update this issue
I have added support of callbacks
Now you can set custom functions via
ORM::configure('cache_query_result', function ($hash) {
});
ORM::configure('check_query_cache', function ($cache_key,$connection_name) {
});
ORM::configure('clear_cache', function ($connection_name) {
});
Closing and moving discussion to pull request.
Hello,
I was able to successfully integrate your library in my project. Thank you for the great work. Idiorm in ingenious! I can now make super complex queries with no problem.
I have a situation here when i need to use my own cache functions
Since those methods are protected: https://github.com/j4mie/idiorm/blob/master/idiorm.php#L1538 https://github.com/j4mie/idiorm/blob/master/idiorm.php#L1548 https://github.com/j4mie/idiorm/blob/master/idiorm.php#L1565
I cannot override them Can you please make them public or suggest some way i can swap them with my own functions
Thanks