def cacheProviderFactory(): recordProvider = queryUtility(ICacheSettingsRecordProvider) if not recordProvider: return NullCache() value = recordProvider().value or '' servers = value.split() if servers: return Memcached(servers) return NullCache()
def cacheProviderFactory(): recordProvider = queryUtility(ICacheSettingsRecordProvider) if not recordProvider: return NullCache() value = recordProvider().value or '' servers = value.split() if servers: # thread safety for memcached connections key = '_v_cacheProviderFactory_Memcached' mcd = getattr(thread_local, key, None) if not mcd: mcd = Memcached(servers) setattr(thread_local, key, mcd) return mcd return NullCache()
def __call__(self): return Memcached(self.servers)
import time import types from zope.component import ComponentLookupError from Products.CMFCore.utils import getToolByName from Products.PlonePAS.interfaces.group import IGroupIntrospection from bda.cache import ICacheManager from bda.cache import Memcached from interfaces import IGenericGroupTranslation from interfaces import IGenericFilterTranslation # make this dynamic, XXX CACHEPROVIDER = Memcached(['127.0.0.1:11211']) class MemberLookup(object): """This object contains the logic to list and search for users and groups. """ def __init__(self, context, request, widget): """Construct this object and do base initialization. """ self.context = context self.widget = widget self.searchabletext = request.get('searchabletext', '') group = request.get('selectgroup', '') try: grouptranslation = IGenericGroupTranslation(self.context) self.currentgroupid = grouptranslation.translateToRealGroupId( group)