Elviss Strazdins Sun Oct 17 16:00:45 -0400 2010
For those of you, who too need this functionality, for now you can do it like this:
1 class Item extends ActiveRecord\Model
2 {
3 public static function find()
4 {
5 $args = func_get_args();
6 if (data_found_in_memcache)
7 {
8 $result = data_from_memcache;
9 }
10 else
11 {
12 $result = call_user_func_array('parent::find', $args);
13 write_data_to_memcache;
14 }
15 return $result;
16 }
17 }
Phil Freo Tue Mar 29 00:53:38 -0400 2011
Were those hooks ever implemented? Is this still the best way to do this?
Seems like having a super easy way to plug in caching is critical to a good ORM
Yoan B Tue Mar 29 06:53:06 -0400 2011
afaik, only those exist:
• (before|after)_create
• (before|after)_destory
• (before|after)_update
• (before|after)_validation
• (before|after)_validation_on_create
• (before|after)_validation_on_update
The ones you are looking for are (before|after)_(create|update) I guess.
see: https://github.com/kla/php-activerecord/blob/master/lib/Model.php#L773
(1-3/3)
Subject: before_find and after_find callbacks
Hi!
Thanks for great work on Php.ActiveRecord. I found it about a week ago and decided to use it in my project. But I need to cache all my data with memcache, so it would be great if you could implement befor_find and after_find callbacks, so that it would be possible to try to read data from memcache in before_find callback and write data to memcache in after_find.
Thanks in advance!