I'm aware of Johnny cache's MAN_IN_BLACKLIST and JOHNNY_TABLE_BLACKLIST. Is there a way to specify the reverse? That is specify only the tables that need to be cached? I want to do this for the simple reason that we have over 200 tables in the application and I want to cache a few and don't want my MAN_IN_BLACKLIST to be really huge.

Thanks,

有帮助吗?

解决方案

Instead of writing tables explicitly, I'm afraid you need to hack johnny/cache.py, mainly lines contains blacklist_match. The easiest way is to modify the function blacklist_match directly:

# set WHITELIST in johnny/settings.py, just as BLACKLIST
WHITELIST = getattr(settings, 'MAN_IN_WHITELIST',
            getattr(settings, 'JOHNNY_TABLE_WHITELIST', []))
WHITELIST = set(WHITELIST)

def blacklist_match(*tables):
    return not WHITELIST.issuperset(tables) or \
           bool(settings.BLACKLIST.intersection(tables))

其他提示

As of version 1.4 Johnny Cache actually supports whitelists. Add JOHNNY_TABLE_WHITELIST to your settings and assign it the list of tables you want to be cached, e.g.:

JOHNNY_TABLE_WHITELIST = ['appname_tablename', 'someotherapp_differenttable']

source

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top