Updated ChannelDBHandler to always return a new database if self.threaded is True.

This commit is contained in:
Jeremy Fincher 2003-08-23 12:38:58 +00:00
parent ade09765bc
commit 5769e4d4cf

View File

@ -23,6 +23,7 @@ class ChannelDBHandler(object):
"""A class to handle database stuff for individual channels transparently. """A class to handle database stuff for individual channels transparently.
""" """
suffix = '.db' suffix = '.db'
threaded = False
def __init__(self, suffix='.db'): def __init__(self, suffix='.db'):
self.dbCache = ircutils.IrcDict() self.dbCache = ircutils.IrcDict()
suffix = self.suffix suffix = self.suffix
@ -40,10 +41,14 @@ class ChannelDBHandler(object):
def getDb(self, channel): def getDb(self, channel):
try: try:
return self.dbCache[channel] if self.threaded:
return self.makeDb(self.makeFilename(channel))
else:
return self.dbCache[channel]
except KeyError: except KeyError:
db = self.makeDb(self.makeFilename(channel)) db = self.makeDb(self.makeFilename(channel))
self.dbCache[channel] = db if not self.threaded:
self.dbCache[channel] = db
return db return db
def die(self): def die(self):