The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Repository::Simple::Engine::Memory - Transient repository storage in memory

SYNOPSIS

  use Repository::Simple;
  my $mem = Repository::Simple->attach('Memory');

DESCRIPTION

This repository uses a transient memory store to store all nodes and properties. This is very simple and cnfigurable.

OPTIONS

You may create this repository with no options to accept all defaults. This will give you an empty repository (i.e., containing only a root node, with no properties). Until writes are implemented, this isn't at all useful, so you will probably want to issue a "root" option to at least specify a structure for the repository.

If you do specify options, you may specify any of the following:

namespaces

This option accepts a hash of namespace prefixes to namespace URIs. This allows you to customize the namespaces used by the storage engine. By default, this contains a single entry "mem".

node_types

This option allows you to create an arbitrary set of node types for storing information in the repository. This should be an array of hashes. Each hash will be passed to the constructor of Repository::Simple::Type::Node (with the "engine" argument added to refer to the newly created engine).

By default, a single node type, "mem:generic-node" is created, which provides very few constraints.

property_types

This option allows you to create an arbitrary set of property types for storing information in the repository. This should be an array of hashes. Each hash will be passed to the constructor of Repository::Simple::Type::Property (with the "engine" argument added to refer to the newly created engine).

By default, a single node type, "mem:generic-property" is created, which provides very few constraints.

root

This option establishes what nodes are initially in the repository. If this option is not included, the repository will be empty, except for the root. If you specify a custom set of node types and do not include "mem:generic-node", you must define this option as the default setting will attempt to create a node with that node type.

The option should be set to a hash reference representing the root node. It must have the "node_type" key set to the name of the node type the root node should have. It may, optionally, also have a "nodes" and a "properties" key.

The "nodes" key, if present, should point to a hash reference where each key is the name of each child node and each hash will have the same form as the root value. Thus, this structure is recursive, each node will be represented by a hash containing a "node_type" key and optionally "nodes" and "properties" keys.

The "properties" key, if present, should point to a hash reference where each eky is the name of each child property. Each hash should contain a "property_type" pointing to the name of the property_type for that value. It may also have a "value" key pointing to the properties value, stored as a scalar value or reference.

For example,

  my %settings = (
      root => {
          node_type => 'mem:generic',
          properties => {
              'foo' => {
                  property_type => 'mem:generic-property',
                  value => 1,
              },
              'bar' => {
                  property_type => 'mem:generic-property',
                  value => 2,
              },
          },
          nodes => {
              'baz' => {
                  node_type => 'mem:generic',
                  nodes => {
                      'qux' => {
                          node_type => 'mem:generic',
                          properties => {
                              quux => {
                                  property_type => 'mem:generic-property',
                                  value => 3,
                              },
                          },
                      },
                  },
              },
          },
      },
  );
  my $repository = Repository::Simple->attach(Memory => %settings);

AUTHOR

Andrew Sterling Hanenkamp, <hanenkamp@cpan.org>

LICENSE AND COPYRIGHT

Copyright 2006 Andrew Sterling Hanenkamp <hanenkamp@cpan.org>. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.