swistak asked:

how are multi-threads handled in Og

Tags:

Is Og using connection-pool to database or single connection ?

(1 attempts)

Kashia answered:

Yes, Og is fully thread-safe. It uses a connection pool (when not using FCGI) with standard 5 connections.

You can modify that behaviour by configuring Og as following:

Og.manager_options.update(
  :connection_count => 3
)

# Og.start

Og internal is thread safe, in your own code you have to be careful:

store = OgKlass.ogmanager.store
store.query("SELECT ...")
OgKlass.ogmanager.put_store(store)

# Or

OgKlass.ogmanager.with_store do |store|
  store.query("SELECT ...")
end

As this is a pool, always remember to free the ressource or you'll get evil deadlocks.

Rating: