I saw a possibility in radioactivity.rules.inc to clear only affected entity field cache instead of all field cache there is, but I'm wondering if this would not break existing functionality?
The actual patch is very small:
+++ radioactivity.rules.inc 2012-12-18 13:36:53.928377264 +0200
@@ -123,7 +123,8 @@
if ($profile && $profile->storageObject) {
$profile->storageObject->addIncident(new RadioactivityIncident($entity_type, $bundle, $field_name, $lang, $id, $energy, time()));
}
- field_cache_clear();
+
+ cache_clear_all("field:$entity_type:$id", 'cache_field');
}
/**
@@ -153,7 +154,7 @@
TRUE
);
- field_cache_clear();
+ cache_clear_all("field:$entity_type:$id", 'cache_field');
}
/**
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | do-1869298-selectively_clear_field_cache.patch | 2.02 KB | heine |
| #1 | radioactivity-field_cache_performance-1869298-1.patch | 1.5 KB | jrbeeman |
Comments
Comment #1
jrbeemanUpdated against latest 7.x-2.x and added similar patch for emit.php. Changed category to bug report as this is a pretty huge performance drain on large sites with lots of user content creation. Without this patch, cache_field churns heavily.
Comment #2
jrbeemanFollow-up: radioactivity_cron() still calls field_cache_clear() and this needs to be resolved.
Comment #3
jrbeemanMarking as needs work in order to resolve the hook_cron() implementation. Updated issue title to be more descriptive.
Comment #4
tcmug commentedWe can't use db_delete to clear caches as it would not work for example memcache or redis caches, right?
So, in that regard this also needs work.
Comment #5
heine commentedIncludes #1. Contains in addition a change to hook_cron to only clear field:[entity_type]: . This could be further optimised when rules is present by keeping an array of item ids and only clearing ids.
Patch is against 7.x-2.9.
Comment #6
heine commentedNote that the patch in #5 doesn't prevent field cache clears from negatively affecting the site's performance; check_markup is called again and again for textfields with cacheable formats on load, because the field cache for the particular entity will be empty (see text_field_load()).