Mercurial > p > roundup > code
diff roundup/backends/rdbms_common.py @ 4074:e039f3cbbb96
Make RDBMS cache-size configurable.
| author | Stefan Seefeld <stefan@seefeld.name> |
|---|---|
| date | Tue, 24 Feb 2009 01:10:13 +0000 |
| parents | 6ea417bafd9c |
| children | 04843a029ea1 |
line wrap: on
line diff
--- a/roundup/backends/rdbms_common.py Mon Feb 23 20:12:23 2009 +0000 +++ b/roundup/backends/rdbms_common.py Tue Feb 24 01:10:13 2009 +0000 @@ -71,9 +71,6 @@ from sessions_rdbms import Sessions, OneTimeKeys from roundup.date import Range -# number of rows to keep in memory -ROW_CACHE_SIZE = 100 - # dummy value meaning "argument not passed" _marker = [] @@ -108,7 +105,7 @@ - some functionality is specific to the actual SQL database, hence the sql_* methods that are NotImplemented - - we keep a cache of the latest ROW_CACHE_SIZE row fetches. + - we keep a cache of the latest N row fetches (where N is configurable). """ def __init__(self, config, journaltag=None): """ Open the database and load the schema from it. @@ -125,6 +122,7 @@ # keep a cache of the N most recently retrieved rows of any kind # (classname, nodeid) = row + self.cache_size = config.RDBMS_CACHE_SIZE self.cache = {} self.cache_lru = [] self.stats = {'cache_hits': 0, 'cache_misses': 0, 'get_items': 0, @@ -1057,7 +1055,7 @@ self.cache[key] = node # update the LRU self.cache_lru.insert(0, key) - if len(self.cache_lru) > ROW_CACHE_SIZE: + if len(self.cache_lru) > self.cache_size: del self.cache[self.cache_lru.pop()] if __debug__:
