Changeset 575
- Timestamp:
- 11/05/07 22:29:41
- Files:
-
- branches/crazycache/dejavu/storage/caching.py (modified) (1 diff)
- branches/crazycache/dejavu/storage/storememcached.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/crazycache/dejavu/storage/caching.py
r574 r575 94 94 # Try to retrieve units using a cached index. 95 95 if cls.identifiers and cls in self.cache.classes: 96 units = self.cache.scan(self.nextstore, cls, expr , order)96 units = self.cache.scan(self.nextstore, cls, expr) 97 97 if units is not None: 98 for unit in units: 98 units = [(unit,) for unit in units] 99 for unit in self._paginate(units, order, limit, offset, single=True): 99 100 yield unit 100 101 return branches/crazycache/dejavu/storage/storememcached.py
r574 r575 496 496 return {} 497 497 498 def scan(self, mainstore, cls, expr , order):499 """Return a n orderedlist of units from a cached index (or None).498 def scan(self, mainstore, cls, expr): 499 """Return a list of units from a cached index (or None). 500 500 501 501 The class and expression will be used to find a cached index; … … 513 513 keyattrs = self.primary_keys[cls] 514 514 515 # Get a cached list of identifier-tuples, ordered if requested. 516 # TODO: add order to the idkey. 515 # Get a cached list of identifier-tuples. 517 516 for index in indexset: 518 517 if set(filters.keys()) >= set(index): … … 526 525 if ids is None: 527 526 # Not in the cache. Grab the list of id-tuples from nextstore. 528 ids = mainstore.view((cls, keyattrs, filters), order=order) 529 # Then cache the list result for next time. 527 ids = mainstore.view((cls, keyattrs, filters)) 528 # Then cache the list result for next time. Note that index 529 # contents are unordered. 530 530 indexset.put(indexcriteria, ids, time=self.index_time) 531 531 … … 580 580 pass 581 581 582 # Preserve order 583 return [units[k] for k in ids] 582 return units.values() 584 583 585 584 … … 723 722 index, although it may and often should contain additional entries. 724 723 """ 725 partial_index = set(filters.keys()) > set(index)726 724 indexcriteria = dict([(k, filters[k]) for k in index]) 727 725 ids = self.get(indexcriteria) … … 730 728 731 729 removals = False 732 # Preserve order by iterating over the retrieved ids 733 # instead of the retrieved units. 734 for id in ids: 735 unit = units.get(id, None) 736 if unit is not None: 737 for k, v in filters.iteritems(): 738 if getattr(unit, k) != v: 739 if k in index: 740 removals = True 741 del units[id] 742 ids.remove(id) 743 break 744 else: 745 unit.cleanse() 746 yield unit 730 for id, unit in units.items(): 731 for k, v in filters.iteritems(): 732 if getattr(unit, k) != v: 733 if k in index: 734 removals = True 735 del units[id] 736 ids.remove(id) 737 break 738 else: 739 unit.cleanse() 740 yield unit 747 741 748 742 if removals:
