class DuckDB::InstanceCache
The DuckDB::InstanceCache
is necessary if a client/program (re)opens multiple databases to the same file within the same statement.
require 'duckdb' cache = DuckDB::InstanceCache.new db1 = cache.get(path: 'db.duckdb') db2 = cache.get(path: 'db.duckdb')
Public Class Methods
Source
static VALUE duckdb_instance_cache_initialize(VALUE self) { rubyDuckDBInstanceCache *ctx; TypedData_Get_Struct(self, rubyDuckDBInstanceCache, &instance_cache_data_type, ctx); ctx->instance_cache = duckdb_create_instance_cache(); if (ctx->instance_cache == NULL) { rb_raise(eDuckDBError, "Failed to create instance cache"); } return self; }
Public Instance Methods
Source
static VALUE duckdb_instance_cache_destroy(VALUE self) { rubyDuckDBInstanceCache *ctx; TypedData_Get_Struct(self, rubyDuckDBInstanceCache, &instance_cache_data_type, ctx); if (ctx->instance_cache) { duckdb_destroy_instance_cache(&(ctx->instance_cache)); ctx->instance_cache = NULL; } return Qnil; }
Source
# File lib/duckdb/instance_cache.rb, line 20 def get(path: nil, config: nil) get_or_create(path, config) end
Returns a DuckDB::Database
object for the given path and config.
db1 = cache.get(path: 'db.duckdb') db2 = cache.get(path: 'db.duckdb')