Added a timeout to the attribute caching; the system will now clean cache at regular intervals once it pass a certain size defined in settings.

This commit is contained in:
Griatch 2012-04-28 00:37:36 +02:00
parent e3ce0a7933
commit 3091587e33
8 changed files with 137 additions and 106 deletions

View file

@ -141,8 +141,10 @@ class Command(object):
input can be either a cmd object or the name of a command.
"""
try:
# first assume input is a command (the most common case)
return cmd.key in self._matchset
except AttributeError: # got a string
except AttributeError:
# probably got a string
return cmd in self._matchset
def __contains__(self, query):
@ -154,7 +156,7 @@ class Command(object):
query (str) - query to match against. Should be lower case.
"""
return any(query in keyalias for keyalias in self._matchset)
return any(query in keyalias for keyalias in self._keyaliases)
def match(self, cmdname):
"""