@@ -131,44 +131,33 @@ class PureCompoundDB(CompoundDB, PureObjectDBR, LazyMixin, CachingDB):
131
131
def _set_cache_ (self , attr ):
132
132
if attr == '_dbs' :
133
133
self ._dbs = list ()
134
- elif attr == '_obj_cache' :
135
- self ._obj_cache = dict ()
136
134
else :
137
135
super (PureCompoundDB , self )._set_cache_ (attr )
138
136
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
-
157
137
#{ PureObjectDBR interface
158
138
159
139
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
166
145
167
146
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
169
153
170
154
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
172
161
173
162
def size (self ):
174
163
return reduce (lambda x ,y : x + y , (db .size () for db in self ._dbs ), 0 )
@@ -185,7 +174,6 @@ def databases(self):
185
174
186
175
def update_cache (self , force = False ):
187
176
# something might have changed, clear everything
188
- self ._obj_cache .clear ()
189
177
stat = False
190
178
for db in self ._dbs :
191
179
if isinstance (db , CachingDB ):
0 commit comments