objectstore.rb

Path: lib/mues/objectstore.rb  (CVS)
Last Update: Sat Aug 18 22:54:10 -0700 2007

This file contains the MUES::ObjectStore class, which is used to provide object persistance for MUES objects.

The ObjectStore is a factory/wrapper class that provides a front end for combining a Strategy for object persistance (a MUES::ObjectStore::Backend) and, optionally, a one for swapping disused objects (mostly) out of memory temporarily via a MUES::ObjectStore::MemoryManager.

Caveats/Requirements

  • All objects stored must inherit from the MUES::StorableObject class.
  • Multiple ObjectStores alive in the same ruby process must have distinct names.

Specifying a Backend or MemoryManager

Not yet done.

Synopsis

  require 'mues/objectstore'
  require 'mues/storableobject'

  $store = MUES::ObjectStore::create(
      :backend => "BerkeleyDB",
      :memmgr          => "PMOS",
      :name        => "mystore"
  )

  objs = []
  ids = []
  40.times do
      newObj = MUES::StorableObject.new
      objs << newObj
      ids << newObj.objectStoreId
  end

  $store.store( *objs )
  $store.retrieve_readonly {|obj| puts obj.attr}

  object = $store.retrieve( "objid" )
  object.attribute_A = 3.14159262546
  $store.store( object )

  $store.close

Version

 $Id: objectstore.rb 1189 2004-05-02 18:39:03Z deveiant $

Authors

  • Martin Chase <stillflame@FaerieMUD.org>
  • Michael Granger <ged@FaerieMUD.org>

Copyright

Copyright (c) 2000-2003 The FaerieMUD Consortium. All rights reserved.

This module is free software. You may use, modify, and/or redistribute this software under the terms of the Perl Artistic License. (See language.perl.com/misc/Artistic.html)

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

Required files

forwardable   sync   mues/object   mues/exceptions   mues/storableobject   mues/objectspacevisitor   mues/os-extensions/backend   mues/os-extensions/memorymanager  

[Validate]