Module: Lite3::SQL

Defined in:
lib/internal_lite3/sql.rb

Overview

This module provides some basic, consistent access to the underlying database library(es) (currently sequel).

Class Method Summary collapse

Class Method Details

.close_allObject

Close and remove the underlying database connections. This does not invalidate existing Lite3::DBM objects; they will recreate the connections when needed.

The main use for this is for safely forking the current process. You should call this just before each fork to avoid potential corruption from duplicated database handles.

This should not be called while a database operation is in progress. (E.g. do not call this from the block of DBM.each.)



84
# File 'lib/internal_lite3/sql.rb', line 84

def self.close_all()    return HandlePool.close_all     end

.gcObject

Disconnect and delete all database handles and associated metadata that are no longer needed (i.e. because their corresponding DBMs have been closed or reclaimed).

Returns a hash mapping the path to each open database file to the number of live DBM objects referencing it.

You normally won't need to explicitly call this, but it's useful for testing and debugging.



71
# File 'lib/internal_lite3/sql.rb', line 71

def self.gc()           return HandlePool.gc;           end

.threadsafe?Boolean

Tests if the underlying database libraries are threadsafe.

(Currently, it always returns true, since Sequel does that for us.)

Returns:

  • (Boolean)


58
59
60
# File 'lib/internal_lite3/sql.rb', line 58

def self.threadsafe?
  return true
end