Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6a10c8a

Browse files
committed
Removed cache in PureCompoundDB as it had the tendency to slow things down actually
1 parent0906450 commit6a10c8a

File tree

1 file changed

+17
-29
lines changed

1 file changed

+17
-29
lines changed

‎git/db/py/base.py

Lines changed: 17 additions & 29 deletions
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
ifattr=='_dbs':
133133
self._dbs=list()
134-
elifattr=='_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-
returnself._obj_cache[sha]
146-
exceptKeyError:
147-
pass
148-
# END first level cache
149-
150-
fordbinself._dbs:
151-
ifdb.has_object(sha):
152-
self._obj_cache[sha]=db
153-
returndb
154-
# END for each database
155-
raiseBadObject(sha)
156-
157137
#{ PureObjectDBR interface
158138

159139
defhas_object(self,sha):
160-
try:
161-
self._db_query(sha)
162-
returnTrue
163-
exceptBadObject:
164-
returnFalse
165-
# END handle exceptions
140+
fordbinself._dbs:
141+
ifdb.has_object(sha):
142+
returnTrue
143+
#END for each db
144+
returnFalse
166145

167146
definfo(self,sha):
168-
returnself._db_query(sha).info(sha)
147+
fordbinself._dbs:
148+
try:
149+
returndb.info(sha)
150+
exceptBadObject:
151+
pass
152+
#END for each db
169153

170154
defstream(self,sha):
171-
returnself._db_query(sha).stream(sha)
155+
fordbinself._dbs:
156+
try:
157+
returndb.stream(sha)
158+
exceptBadObject:
159+
pass
160+
#END for each db
172161

173162
defsize(self):
174163
returnreduce(lambdax,y:x+y, (db.size()fordbinself._dbs),0)
@@ -185,7 +174,6 @@ def databases(self):
185174

186175
defupdate_cache(self,force=False):
187176
# something might have changed, clear everything
188-
self._obj_cache.clear()
189177
stat=False
190178
fordbinself._dbs:
191179
ifisinstance(db,CachingDB):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp