Skip to content

Commit

Permalink
Merge pull request #192 from jeremycline/load-rules-once
Browse files Browse the repository at this point in the history
Cache the rule-loading code
  • Loading branch information
jeremycline committed May 30, 2017
2 parents 061c10d + 4004a91 commit 8b3b69b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fmn/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import re
import smtplib

from dogpile.cache import make_region
from dogpile.cache.util import kwarg_function_key_generator
import bs4
import docutils.examples
import fedmsg
Expand Down Expand Up @@ -154,6 +156,12 @@ def update_preferences(openid, existing_preferences):
return existing_preferences


#: A dictionary-backed cache that maps Python paths to a set of rules.
_rule_cache = make_region(function_key_generator=kwarg_function_key_generator)
_rule_cache.configure('dogpile.cache.memory')


@_rule_cache.cache_on_arguments()
def load_rules(root='fmn.rules'):
""" Load the big list of allowed callable rules. """

Expand Down

0 comments on commit 8b3b69b

Please sign in to comment.