Hi Fabio,
On Tue, Sep 22, 2009 at 1:15 PM, Fabio Mascarenhas <[email protected]>wrote:
> Sorry Ryan, I sent a slightly old version of the recycle function by
> mistake, this is the correct one (avoids resource leaks while the old
> connection is not collected, in case it is still valid, plus does not
> log "new conn" to the console):
>
> ---------
> function recycle(fresh_conn, timeout)
> local created_at = os.time()
> local conn = fresh_conn()
> timeout = timeout or 20000
> return setmetatable({}, { __index = function (tab, meth)
> tab[meth] = function (tab, ...)
> if created_at +
> timeout < os.time() then
> created_at =
> os.time()
> pcall(conn.close,
> conn)
> conn =
> fresh_conn()
> end
> return
> conn[meth](conn, ...)
> end
> return tab[meth]
> end
> })
> end
> -------------
>
>
I added it to the model.lua file. I will wait till tomorrow to see how it
goes. Thanks so much for the help.
--
Regards,
Ryan
_______________________________________________
Kepler-Project mailing list
[email protected]
http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
http://www.keplerproject.org/