Commit 6ef5cd2e authored by Chris Withers's avatar Chris Withers

- replace nasty and ineffective hack for dynamic connections ids in ZSQL...

- replace nasty and ineffective hack for dynamic connections ids in ZSQL Method cache which is tested and works
- simplify tests as a result
- make sure full chain of DA.__call__ and DA._cached_result is execercised
parent 01cd806e
...@@ -352,11 +352,8 @@ class DA( ...@@ -352,11 +352,8 @@ class DA(
def _searchable_result_columns(self): return self._col def _searchable_result_columns(self): return self._col
def _cached_result(self, DB__, query): def _cached_result(self, DB__, query, max_rows, conn_id):
pure_query = query cache_key = query,max_rows,conn_id
# we need to munge the incoming query key in the cache
# so that the same request to a different db is returned
query = query + ('\nDBConnId: %s' % self.connection_hook, )
# Try to fetch from cache # Try to fetch from cache
if hasattr(self,'_v_cache'): cache=self._v_cache if hasattr(self,'_v_cache'): cache=self._v_cache
...@@ -376,15 +373,15 @@ class DA( ...@@ -376,15 +373,15 @@ class DA(
del cache[q] del cache[q]
del keys[-1] del keys[-1]
if cache.has_key(query): if cache.has_key(cache_key):
k, r = cache[query] k, r = cache[cache_key]
if k > t: return r if k > t: return r
# call the pure query # call the pure query
result=apply(DB__.query, pure_query) result=DB__.query(query,max_rows)
if self.cache_time_ > 0: if self.cache_time_ > 0:
tcache[int(now)]=query tcache[int(now)]=cache_key
cache[query]= now, result cache[cache_key]= now, result
return result return result
...@@ -450,8 +447,9 @@ class DA( ...@@ -450,8 +447,9 @@ class DA(
if src__: return query if src__: return query
if self.cache_time_ > 0 and self.max_cache_ > 0: if self.cache_time_ > 0 and self.max_cache_ > 0:
result=self._cached_result(DB__, (query, self.max_rows_)) result=self._cached_result(DB__, query, self.max_rows_, c)
else: result=DB__.query(query, self.max_rows_) else:
result=DB__.query(query, self.max_rows_)
if hasattr(self, '_v_brain'): brain=self._v_brain if hasattr(self, '_v_brain'): brain=self._v_brain
else: else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment