From 001f35a6bde645b5cbd67a43fabf1976aa2025f0 Mon Sep 17 00:00:00 2001 From: stefan Date: Tue, 24 Feb 2009 01:10:13 +0000 Subject: [PATCH] Make RDBMS cache-size configurable. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4166 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/backends/rdbms_common.py | 8 +++----- roundup/configuration.py | 8 +++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/roundup/backends/rdbms_common.py b/roundup/backends/rdbms_common.py index 76243d2..31aa0ac 100644 --- a/roundup/backends/rdbms_common.py +++ b/roundup/backends/rdbms_common.py @@ -71,9 +71,6 @@ except ImportError: 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 @@ class Database(FileStorage, hyperdb.Database, roundupdb.Database): - 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 @@ class Database(FileStorage, hyperdb.Database, roundupdb.Database): # 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 @@ class Database(FileStorage, hyperdb.Database, roundupdb.Database): 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__: diff --git a/roundup/configuration.py b/roundup/configuration.py index 4fa4c94..8d03f7b 100644 --- a/roundup/configuration.py +++ b/roundup/configuration.py @@ -370,7 +370,7 @@ class OctalNumberOption(Option): class NullableOption(Option): - """Option that is set to None if it's string value is one of NULL strings + """Option that is set to None if its string value is one of NULL strings Default nullable strings list contains empty string only. There is constructor parameter allowing to specify different nullables. @@ -592,8 +592,10 @@ SETTINGS = ( (NullableOption, 'read_default_group', 'roundup', "Name of the group to use in the MySQL defaults file (.my.cnf).\n" "Only used in MySQL connections."), + (IntegerNumberOption, 'cache_size', '100', + "Size of the node cache (in elements)"), ), "Settings in this section are used" - " by Postgresql and MySQL backends only" + " by RDBMS backends only" ), ("logging", ( (FilePathOption, "config", "", @@ -874,7 +876,7 @@ class Config: _options.append(_name) # (section, name) key is used for writing .ini file self.options[(_section, _name)] = option - # make the option known under all of it's A.K.A.s + # make the option known under all of its A.K.A.s for _name in option.aliases: self.options[_name] = option -- 2.30.2