Commit 0a77ad93 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add some utility methods for a cache per transaction. This cache is only for a...

Add some utility methods for a cache per transaction. This cache is only for a read-only transaction.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4626 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 68b422c2
......@@ -142,3 +142,31 @@ allow_class(CachingMethod)
def clearCache():
CachingMethod.cached_object_dict.clear()
# TransactionCache is a cache per transaction. The purpose of this cache is
# to accelerate some heavy read-only operations. Note that this must not be
# enabled when a trasaction may modify ZODB objects.
def getTransactionCache(context):
"""Get the transaction cache.
"""
try:
return context.REQUEST._erp5_transaction_cache
except AttributeError:
return None
def enableTransactionCache(context):
"""Enable the transaction cache.
"""
try:
context.REQUEST._erp5_transaction_cache = {}
except AttributeError:
pass
def disableTransactionCache(context):
"""Disable the transaction cache.
"""
try:
del context.REQUEST._erp5_transaction_cache
except AttributeError:
pass
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment