view · edit · sidebar · attach · print · history

ODBA Transparent Hash Access

<< FulltextIndex | Index | TransactionRollback >>

 require 'odba'

 class Container
   include ODBA::Persistable
   attr_reader :table
   def initialize
     @table = Hash.new
   end
 end

 ODBA.storage.dbi = DBI.connect('DBI:pg:test', 'hwyss', '')
 container = ODBA.cache.fetch_named('container', self) {
   Container.new
 }

 value = Container.new
 container.table.store('key', value)
 container.table.odba_store

 ODBA.cache.clear

 container = ODBA.cache.fetch_named('container', self)
 table = container.table
 raise unless table['key']
 raise unless table.is_a?(ODBA::Stub)
 table['key'].class

returns

 Container
view · edit · sidebar · attach · print · history
Page last modified on March 15, 2011, at 03:42 PM