Changed a few caches to use CacheDict to ensure no without-bound growth on caches.

This commit is contained in:
Jeremy Fincher 2009-04-02 11:45:00 -05:00
parent 757991afc9
commit dd4bc64e32
2 changed files with 5 additions and 5 deletions

View File

@ -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):

View File

@ -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."""