658 |
658 |
659 # data sources handling ################################################### |
659 # data sources handling ################################################### |
660 # * correspondance between eid and type |
660 # * correspondance between eid and type |
661 # * correspondance between eid and local id (i.e. specific to a given source) |
661 # * correspondance between eid and local id (i.e. specific to a given source) |
662 |
662 |
663 def clear_caches(self, eids): |
663 def clear_caches(self, eids=None): |
664 etcache = self._type_cache |
664 if eids is None: |
665 rqlcache = self.querier.rql_cache |
665 self._type_cache = {} |
666 for eid in eids: |
666 etypes = None |
667 try: |
667 else: |
668 etype = etcache.pop(int(eid)) # may be a string in some cases |
668 etypes = [] |
669 rqlcache.pop(('%s X WHERE X eid %s' % (etype, eid),), None) |
669 etcache = self._type_cache |
670 except KeyError: |
670 rqlcache = self.querier.rql_cache |
671 etype = None |
671 for eid in eids: |
672 rqlcache.pop(('Any X WHERE X eid %s' % eid,), None) |
672 try: |
673 self.system_source.clear_eid_cache(eid, etype) |
673 etype = etcache.pop(int(eid)) # may be a string in some cases |
|
674 rqlcache.pop(('%s X WHERE X eid %s' % (etype, eid),), None) |
|
675 except KeyError: |
|
676 etype = None |
|
677 rqlcache.pop(('Any X WHERE X eid %s' % eid,), None) |
|
678 etypes.append(etype) |
|
679 self.system_source.clear_caches(eids, etypes) |
674 |
680 |
675 def type_from_eid(self, eid, cnx): |
681 def type_from_eid(self, eid, cnx): |
676 """Return the type of the entity with id `eid`""" |
682 """Return the type of the entity with id `eid`""" |
677 try: |
683 try: |
678 eid = int(eid) |
684 eid = int(eid) |