diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-03-30 23:30:31 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-03-30 23:30:31 +0000 |
commit | 0f8896e6fa692c0a91eb0980700bee069eddc8ef (patch) | |
tree | fbee55c4b9682fc993c4b54a7f797a82d9fd6cf3 /lib/sqlalchemy/pool.py | |
parent | 5291acd5974632433cd89a6aa5828224673878ed (diff) | |
download | sqlalchemy-0f8896e6fa692c0a91eb0980700bee069eddc8ef.tar.gz |
- reverted previous "strings instead of tuples" change due to more specific test results showing tuples faster
- changed cache decorator call on default_schema_name call to a connection.info specific one
Diffstat (limited to 'lib/sqlalchemy/pool.py')
-rw-r--r-- | lib/sqlalchemy/pool.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index 94d9127f0..e22d1d8d3 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -58,6 +58,21 @@ def clear_managers(): manager.close() proxies.clear() +def connection_cache_decorator(func): + """apply caching to the return value of a function, using + the 'info' collection on its given connection.""" + + name = func.__name__ + + def do_with_cache(self, connection): + try: + return connection.info[name] + except KeyError: + value = func(self, connection) + connection.info[name] = value + return value + return do_with_cache + class Pool(object): """Base class for connection pools. |