Index: TODO =================================================================== diff -u -r833cb4b2fb84ddf0aebfc134be2013119c6f668d -rece9e8e60ebe51b69dcb0511110a030d7c71f59f --- TODO (.../TODO) (revision 833cb4b2fb84ddf0aebfc134be2013119c6f668d) +++ TODO (.../TODO) (revision ece9e8e60ebe51b69dcb0511110a030d7c71f59f) @@ -4829,7 +4829,10 @@ - fix stub provisioning for Tcl 8.6 - reduce verbosity for FreeUnsetTraceVariable - return TCL_OK, even when FreeUnsetTraceVariable() fails (warning stays) - + +nx-mongo: +- implement simple persistent handle management based on per-thread objects + ======================================================================== TODO: Index: library/mongodb/nsfmongo.c =================================================================== diff -u -rccb2c99f6fb6f381dfc7e300584ac08e3d2809d3 -rece9e8e60ebe51b69dcb0511110a030d7c71f59f --- library/mongodb/nsfmongo.c (.../nsfmongo.c) (revision ccb2c99f6fb6f381dfc7e300584ac08e3d2809d3) +++ library/mongodb/nsfmongo.c (.../nsfmongo.c) (revision ece9e8e60ebe51b69dcb0511110a030d7c71f59f) @@ -457,6 +457,7 @@ return TCL_OK; } + /* cmd connect NsfMongoConnect { {-argName "-replica-set" -required 0 -nrargs 1} Index: library/mongodb/nx-mongo.tcl =================================================================== diff -u -r47a15b921dd9cd528789a2ae33a3eb841f7356c2 -rece9e8e60ebe51b69dcb0511110a030d7c71f59f --- library/mongodb/nx-mongo.tcl (.../nx-mongo.tcl) (revision 47a15b921dd9cd528789a2ae33a3eb841f7356c2) +++ library/mongodb/nx-mongo.tcl (.../nx-mongo.tcl) (revision ece9e8e60ebe51b69dcb0511110a030d7c71f59f) @@ -25,11 +25,30 @@ ::nx::Object create ::nx::mongo::db { :object property db :object property mongoConn + :public object method connect {{-db test} args} { + if {[info exists :db]} { + if {${:db} eq $db} { + # reuse existing connection + return ${:mongoConn} + } + ::mongo::close ${:mongoConn} + } set :db $db set :mongoConn [::mongo::connect {*}$args] } - :public object method close {} {::mongo::close ${:mongoConn}} + :public object method close {} { + ::mongo::close ${:mongoConn} + unset :db :mongoConn + } + + :public object method destroy {} { + if {[info exists :db]} { + ::nsf::log notice "nx::mongo: auto close connection to database '${:db}'" + ::mongo::close ${:mongoConn} + } + } + :public object method count {args} {::mongo::count ${:mongoConn} {*}$args} :public object method index {args} {::mongo::index ${:mongoConn} {*}$args} :public object method insert {args} {::mongo::insert ${:mongoConn} {*}$args} @@ -644,3 +663,10 @@ } } + +# +# Local variables: +# mode: tcl +# tcl-indent-level: 2 +# indent-tabs-mode: nil +# End: