[repo cache] there are some relations we don't want to cache, they may cause memory leak stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 11 May 2011 19:03:16 +0200
branchstable
changeset 7373 e5e6ef56cfb5
parent 7372 65bd75f16d65
child 7374 3c9850d929e5
[repo cache] there are some relations we don't want to cache, they may cause memory leak
server/repository.py
--- a/server/repository.py	Wed May 11 19:02:27 2011 +0200
+++ b/server/repository.py	Wed May 11 19:03:16 2011 +0200
@@ -59,13 +59,18 @@
      security_enabled
 from cubicweb.server.ssplanner import EditedEntity
 
+NO_CACHE_RELATIONS = set( [('require_permission', 'object'),
+                           ('owned_by', 'object'),
+                           ('created_by', 'object'),
+                           ('cw_source', 'object'),
+                           ])
 
 def prefill_entity_caches(entity, relations):
     session = entity._cw
     # prefill entity relation caches
     for rschema in entity.e_schema.subject_relations():
         rtype = str(rschema)
-        if rtype in schema.VIRTUAL_RTYPES:
+        if rtype in schema.VIRTUAL_RTYPES or (rtype, 'subject') in NO_CACHE_RELATIONS:
             continue
         if rschema.final:
             entity.cw_attr_cache.setdefault(rtype, None)
@@ -74,7 +79,7 @@
                                          session.empty_rset())
     for rschema in entity.e_schema.object_relations():
         rtype = str(rschema)
-        if rtype in schema.VIRTUAL_RTYPES:
+        if rtype in schema.VIRTUAL_RTYPES or (rtype, 'object') in NO_CACHE_RELATIONS:
             continue
         entity.cw_set_relation_cache(rtype, 'object', session.empty_rset())
     # set inlined relation cache before call to after_add_entity