Set the garbage collection policy for the current connection.
MCO_GC_POLICY mco_trans_set_gc_policy( /*IN*/ mco_db_h db,
/*IN*/ MCO_GC_POLICY new_policy );
db
mco_db_connect().new_policy
MCO_GC_DISABLED — garbage collection is disabled.MCO_GC_SELF_VERSIONS — each session performs a cleanup of its own garbage only. This policy
can be efficient when each session (connection) works with its own subset of classes (tables).MCO_GC_ON_MODIFICATION — (default) read-write transactions in any session perform
garbage collection in all sessions (connections).MCO_GC_ALWAYS — like MCO_GC_ON_MODIFICATION, but READ_ONLY
transactions trigger garbage collection as well.This function sets the garbage collection policy for the given session (connection). It should be called only once when a database session (connection) is created, and before any transactions are started. Furthermore, all sessions (connections) should explicitly set the same policy, unless the default is used (an exception is made for
MCO_GC_DISABLED).The
MCO_GC_DISABLEDpolicy is intended to be used to limit garbage collection to dedicated sessions (connections). In this scenario, the worker sessions will have this policy, whereas a dedicated session (or multiple sessions) with policyMCO_GC_ALWAYSwill collect garbage in separate threads.The default policy is
MCO_GC_ON_MODIFICATION.
MCO_GC_POLICY
Application snippet:
const char * dbname = "SimpleDb";
int main(int argc, char* argv[])
{
mco_db_h db;
MCO_RET rc;
mco_device_t dev;
mco_db_params_t db_params;
...
rc = mco_db_open_dev( dbname, simple_get_dictionary(), &dev, 1, &db_params );
if ( MCO_S_OK != rc )
{
rc = mco_db_connect( dbname, &db );
...
mco_trans_set_gc_policy( db, MCO_GC_SELF_VERSIONS );
...
}
...
}