diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2011-07-07 21:47:02 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2011-07-07 21:47:02 +0200 |
commit | 6a10c8a82adcbe1f18c2e79a9135c7f5c753b826 (patch) | |
tree | 309bd1b5dc873cb0b364d5a79e04ce8e19971697 /git/db/py/base.py | |
parent | 09064504e52a5ec8bfc4825a3176239b731380d2 (diff) | |
download | gitpython-6a10c8a82adcbe1f18c2e79a9135c7f5c753b826.tar.gz |
Removed cache in PureCompoundDB as it had the tendency to slow things down actually
Diffstat (limited to 'git/db/py/base.py')
-rw-r--r-- | git/db/py/base.py | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/git/db/py/base.py b/git/db/py/base.py index fb6e2f4a..49f28a8d 100644 --- a/git/db/py/base.py +++ b/git/db/py/base.py @@ -131,44 +131,33 @@ class PureCompoundDB(CompoundDB, PureObjectDBR, LazyMixin, CachingDB): def _set_cache_(self, attr): if attr == '_dbs': self._dbs = list() - elif attr == '_obj_cache': - self._obj_cache = dict() else: super(PureCompoundDB, self)._set_cache_(attr) - def _db_query(self, sha): - """:return: database containing the given 20 byte sha - :raise BadObject:""" - # most databases use binary representations, prevent converting - # it everytime a database is being queried - try: - return self._obj_cache[sha] - except KeyError: - pass - # END first level cache - - for db in self._dbs: - if db.has_object(sha): - self._obj_cache[sha] = db - return db - # END for each database - raise BadObject(sha) - #{ PureObjectDBR interface def has_object(self, sha): - try: - self._db_query(sha) - return True - except BadObject: - return False - # END handle exceptions + for db in self._dbs: + if db.has_object(sha): + return True + #END for each db + return False def info(self, sha): - return self._db_query(sha).info(sha) + for db in self._dbs: + try: + return db.info(sha) + except BadObject: + pass + #END for each db def stream(self, sha): - return self._db_query(sha).stream(sha) + for db in self._dbs: + try: + return db.stream(sha) + except BadObject: + pass + #END for each db def size(self): return reduce(lambda x,y: x+y, (db.size() for db in self._dbs), 0) @@ -185,7 +174,6 @@ class PureCompoundDB(CompoundDB, PureObjectDBR, LazyMixin, CachingDB): def update_cache(self, force=False): # something might have changed, clear everything - self._obj_cache.clear() stat = False for db in self._dbs: if isinstance(db, CachingDB): |