Skip to content

Commit 6a10c8a

Browse files
committed
Removed cache in PureCompoundDB as it had the tendency to slow things down actually
1 parent 0906450 commit 6a10c8a

File tree

1 file changed

+17
-29
lines changed

1 file changed

+17
-29
lines changed

git/db/py/base.py

+17-29
Original file line numberDiff line numberDiff line change
@@ -131,44 +131,33 @@ class PureCompoundDB(CompoundDB, PureObjectDBR, LazyMixin, CachingDB):
131131
def _set_cache_(self, attr):
132132
if attr == '_dbs':
133133
self._dbs = list()
134-
elif attr == '_obj_cache':
135-
self._obj_cache = dict()
136134
else:
137135
super(PureCompoundDB, self)._set_cache_(attr)
138136

139-
def _db_query(self, sha):
140-
""":return: database containing the given 20 byte sha
141-
:raise BadObject:"""
142-
# most databases use binary representations, prevent converting
143-
# it everytime a database is being queried
144-
try:
145-
return self._obj_cache[sha]
146-
except KeyError:
147-
pass
148-
# END first level cache
149-
150-
for db in self._dbs:
151-
if db.has_object(sha):
152-
self._obj_cache[sha] = db
153-
return db
154-
# END for each database
155-
raise BadObject(sha)
156-
157137
#{ PureObjectDBR interface
158138

159139
def has_object(self, sha):
160-
try:
161-
self._db_query(sha)
162-
return True
163-
except BadObject:
164-
return False
165-
# END handle exceptions
140+
for db in self._dbs:
141+
if db.has_object(sha):
142+
return True
143+
#END for each db
144+
return False
166145

167146
def info(self, sha):
168-
return self._db_query(sha).info(sha)
147+
for db in self._dbs:
148+
try:
149+
return db.info(sha)
150+
except BadObject:
151+
pass
152+
#END for each db
169153

170154
def stream(self, sha):
171-
return self._db_query(sha).stream(sha)
155+
for db in self._dbs:
156+
try:
157+
return db.stream(sha)
158+
except BadObject:
159+
pass
160+
#END for each db
172161

173162
def size(self):
174163
return reduce(lambda x,y: x+y, (db.size() for db in self._dbs), 0)
@@ -185,7 +174,6 @@ def databases(self):
185174

186175
def update_cache(self, force=False):
187176
# something might have changed, clear everything
188-
self._obj_cache.clear()
189177
stat = False
190178
for db in self._dbs:
191179
if isinstance(db, CachingDB):

0 commit comments

Comments
 (0)