From dd4bc64e3206bd80883686f540d143dae0886242 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 2 Apr 2009 11:45:00 -0500 Subject: [PATCH] Changed a few caches to use CacheDict to ensure no without-bound growth on caches. --- src/ircdb.py | 6 +++--- src/ircutils.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ircdb.py b/src/ircdb.py index 9c81b48a3..edd5ad5db 100644 --- a/src/ircdb.py +++ b/src/ircdb.py @@ -1,5 +1,5 @@ ### -# Copyright (c) 2002-2005, Jeremiah Fincher +# Copyright (c) 2002-2009, Jeremiah Fincher # Copyright (c) 2009, James Vega # All rights reserved. # @@ -566,8 +566,8 @@ class UsersDictionary(utils.IterableMap): self.filename = None self.users = {} self.nextId = 0 - self._nameCache = {} - self._hostmaskCache = {} + self._nameCache = utils.structures.CacheDict(1000) + self._hostmaskCache = utils.structures.CacheDict(1000) # This is separate because the Creator has to access our instance. def open(self, filename): diff --git a/src/ircutils.py b/src/ircutils.py index 7a3b3edd0..d8c67a78a 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -140,7 +140,7 @@ def isChannel(s, chantypes='#&+!', channellen=50): len(s) <= channellen and \ len(s.split(None, 1)) == 1 -_patternCache = {} +_patternCache = utils.structures.CacheDict(1000) # Arbitrarily chosen. def _hostmaskPatternEqual(pattern, hostmask): try: return _patternCache[pattern](hostmask) is not None @@ -168,7 +168,7 @@ def _hostmaskPatternEqual(pattern, hostmask): _patternCache[pattern] = f return f(hostmask) is not None -_hostmaskPatternEqualCache = {} +_hostmaskPatternEqualCache = utils.structures.CacheDict{1000) # Arbitrarily chosen.} def hostmaskPatternEqual(pattern, hostmask): """pattern, hostmask => bool Returns True if hostmask matches the hostmask pattern pattern."""