本文整理汇总了Python中Products.StandardCacheManagers.RAMCacheManager类的典型用法代码示例。如果您正苦于以下问题:Python RAMCacheManager类的具体用法?Python RAMCacheManager怎么用?Python RAMCacheManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RAMCacheManager类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: install_RSSCache
def install_RSSCache(portal, out):
if 'RSSCache' not in portal.objectIds():
RAMCacheManager.manage_addRAMCacheManager(portal, 'RSSCache')
portal.RSSCache.manage_editProps('RSSCache for getRSSResult', \
settings={ 'threshold':1000,
'request_vars':['itemCount', 'rssUrl'],
'cleanup_interval':300,
'max_age':3600})
out.write( "added and initalized RAMCache" )
示例2: test_customize_caching
def test_customize_caching(self):
# Test to ensure that cache manager associations survive customizing
cache_id = "gofast"
RAMCacheManager.manage_addRAMCacheManager(self.root, cache_id, REQUEST=None)
self.fsDTML.ZCacheable_setManagerId(cache_id, REQUEST=None)
self.assertEqual(self.fsDTML.ZCacheable_getManagerId(), cache_id)
self.fsDTML.manage_doCustomize(folder_path="custom")
custom_pt = self.custom.testDTML
self.assertEqual(custom_pt.ZCacheable_getManagerId(), cache_id)
示例3: setupRAMCache
def setupRAMCache(portal, logger, ram_cache_id, title, age, reqvars, threshold):
if not ram_cache_id in portal.objectIds():
RAMCacheManager.manage_addRAMCacheManager(portal, ram_cache_id)
cache = getattr(portal, ram_cache_id)
settings = cache.getSettings()
settings['max_age'] = age
settings['request_vars'] = reqvars
settings['threshold'] = threshold
cache.manage_editProps(title, settings)
logger.info(' - created RAMCache %s' % ram_cache_id)
else:
logger.info(' - already exists RAMCache "%s"' % ram_cache_id)
示例4: test_customize_caching
def test_customize_caching(self):
# Test to ensure that cache manager associations survive customizing
cache_id = 'gofast'
RAMCacheManager.manage_addRAMCacheManager(self.app, cache_id,
REQUEST=None)
self.fsPT.ZCacheable_setManagerId(cache_id, REQUEST=None)
self.assertEqual(self.fsPT.ZCacheable_getManagerId(), cache_id)
self.fsPT.manage_doCustomize(folder_path='custom')
custom_pt = self.custom.testPT
self.assertEqual(custom_pt.ZCacheable_getManagerId(), cache_id)
示例5: test_customize_caching
def test_customize_caching(self):
# Test to ensure that cache manager associations survive customizing
root, tool, custom, fsdir, fsPS = self._makeSkins()
cache_id = "gofast"
RAMCacheManager.manage_addRAMCacheManager(root, cache_id, REQUEST=None)
fsPS.ZCacheable_setManagerId(cache_id, REQUEST=None)
self.assertEqual(fsPS.ZCacheable_getManagerId(), cache_id)
fsPS.manage_doCustomize(folder_path="custom")
custom_ps = custom.test6
self.assertEqual(custom_ps.ZCacheable_getManagerId(), cache_id)
示例6: test_customize_caching
def test_customize_caching(self):
# Test to ensure that cache manager associations survive customizing
from Products.StandardCacheManagers import RAMCacheManager
cache_id = 'gofast'
self.custom.all_meta_types = ZPT_META_TYPES
RAMCacheManager.manage_addRAMCacheManager(self.app, cache_id,
REQUEST=None)
self.fsReST.ZCacheable_setManagerId(cache_id, REQUEST=None)
self.assertEqual(self.fsReST.ZCacheable_getManagerId(), cache_id)
self.fsReST.manage_doCustomize(folder_path='custom')
custom_pt = self.custom.testReST
self.assertEqual(custom_pt.ZCacheable_getManagerId(), cache_id)
示例7: test_customize_caching
def test_customize_caching(self):
# Test to ensure that cache manager associations survive customizing
_stool, custom, _fsdir, fsPS = self._makeContext('test6', 'test6.py')
cache_id = 'gofast'
RAMCacheManager.manage_addRAMCacheManager(self.app, cache_id,
REQUEST=None)
fsPS.ZCacheable_setManagerId(cache_id, REQUEST=None)
self.assertEqual(fsPS.ZCacheable_getManagerId(), cache_id)
fsPS.manage_doCustomize(folder_path='custom')
custom_ps = custom.test6
self.assertEqual(custom_ps.ZCacheable_getManagerId(), cache_id)
示例8: addCacheForResourceRegistry
def addCacheForResourceRegistry(context):
portal = getToolByName(context, 'portal_url').getPortalObject()
ram_cache_id = 'ResourceRegistryCache'
if not ram_cache_id in portal.objectIds():
RAMCacheManager.manage_addRAMCacheManager(portal, ram_cache_id)
cache = getattr(portal, ram_cache_id)
settings = cache.getSettings()
settings['max_age'] = 24*3600 # keep for up to 24 hours
settings['request_vars'] = ('URL',)
cache.manage_editProps('Cache for saved ResourceRegistry files', settings)
logger.info('Created RAMCache %s for ResourceRegistry output' % ram_cache_id)
reg = getToolByName(portal, 'portal_css', None)
if reg is not None and getattr(aq_base(reg), 'ZCacheable_setManagerId', None) is not None:
reg.ZCacheable_setManagerId(ram_cache_id)
reg.ZCacheable_setEnabled(1)
logger.info('Associated portal_css with %s' % ram_cache_id)
reg = getToolByName(portal, 'portal_javascripts', None)
if reg is not None and getattr(aq_base(reg), 'ZCacheable_setManagerId', None) is not None:
reg.ZCacheable_setManagerId(ram_cache_id)
reg.ZCacheable_setEnabled(1)
logger.info('Associated portal_javascripts with %s' % ram_cache_id)