Added beaker's "get_cache" helper function
authorThierry Florac <thierry.florac@onf.fr>
Tue, 27 Jun 2017 13:58:13 +0200
changeset 8 09517b76155b
parent 7 a9b43f8fe167
child 9 d01adb2493f0
Added beaker's "get_cache" helper function
src/pyams_cache/beaker.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_cache/beaker.py	Tue Jun 27 13:58:13 2017 +0200
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+
+# import packages
+from beaker import cache
+
+
+def get_cache(region, cache_name):
+    """Get Beaker cache matching given name"""
+    cache_manager = cache.CacheManager(**cache.cache_regions[region])
+    return cache_manager.get_cache(cache_name)