On Wed, 2015-02-18 at 04:21 -0500, Naveed Massjouni wrote: > On Wed, Feb 18, 2015 at 4:09 AM, Andrew Beverley <[email protected]> wrote: > > On Wed, 2015-02-18 at 03:18 -0500, Naveed Massjouni wrote: > >> > The advantage of this is that you can reuse the same database connection > >> > handle. From what I can tell, reusing one plugin inside another would > >> > still open another database connection. Not a major issue, but it seems > >> > cleaner to use an existing one. > >> > >> In the case of the DBIC plugin, its schema keyword is essentially > >> memoized (schema objects are cached in memory), so it would not open > >> another database connection. Unless of course if schema() was called > >> with a different argument. > > > > It's only memoized within each instantiation of the object. So if you > > "use Dancer2::Plugin::DBIC" within another plugin, you get a second > > connection. Correct? > > > > Andy > > I don't think that is correct. The schema objects are cached in a > $schemas hashref that is lexically scoped to the Dancer2::Plugin::DBIC > package. > https://github.com/ironcamel/Dancer2-Plugin-DBIC/blob/master/lib/Dancer2/Plugin/DBIC.pm#L11 > There can only be one instance of this "cache" (the $schemas hashref) > per process.
Thanks for the feedback Naveed. It prompted me to take another look at what I was trying to do with the DPAE DBIC plugin, and I think I've found another way of doing it. I'll post a PR shortly. Thanks, Andy _______________________________________________ dancer-users mailing list [email protected] http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
