From 1942ccc9b683f32d27423b8de3c54cffe753fac0 Mon Sep 17 00:00:00 2001 From: Scott Walters Date: Thu, 10 Mar 2011 20:06:41 -0500 Subject: [PATCH] Let CHI modules other than just DBI get their hands on dbh and perhaps other things in the future; add an "args" : [ "dbh" ] entry to the "cache" : { } config block --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Cache/CHI.pm | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 114bdfa2e..428711e47 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -6,6 +6,7 @@ - added: LastModifiedBy macro - added: Group Manager form control - fixed #12050: Thing query caching #1 + - added: Let CHI cache request $dbh via an "args" : [ "dbh" ] cache conf 7.10.11 - fixed #12057: WebGUI::Search, assetIds search clause diff --git a/lib/WebGUI/Cache/CHI.pm b/lib/WebGUI/Cache/CHI.pm index 3f89e4e5d..f976133c9 100644 --- a/lib/WebGUI/Cache/CHI.pm +++ b/lib/WebGUI/Cache/CHI.pm @@ -99,7 +99,13 @@ sub new { # Default values my $resolveConf = sub { my ($config) = @_; - if ( $config->{driver} =~ /DBI/ ) { + if ( + $config->{driver} =~ /DBI/ or ( + $config->{args} and # "args" : [ "dbh" ] in the "cache": { } block? + ref $config->{args} eq 'ARRAY' and + grep($_ eq 'dbh', @{ $config->{args} }) + ) + ) { $config->{ dbh } = $session->db->dbh; } if ( $config->{driver} =~ /File|FastMmap|BerkeleyDB/ ) {