Config of a Store
Kjetil Kjernsmo
kjetil at kjernsmo.net
Sun Jun 27 14:17:30 CEST 2010
Hi Greg and the rest! :-)
I was thinking about how we do configuration of an RDF::Trine::Store. While
new_with_string has been useful, it has also become a little hard to work
with for some of the stuff I've been doing, so rather than discuss in the
little overlapping IRC time we have, I figured I'd bring it to the list.
I feel that it would be better to pass a hashref with the config, than
coming up with a universal string to work in all circumstances. For
example, I currently need to load a TriG file with a relative path in the
filesystem, and it seems I have to specify the syntax and the base URI, and
I can't currently do that. Also, we run the risk of having the syntax for
each subclass diverge too much. In the future, I may also been interested
in stuff like checking and reload the file if it has changed.
In addition, it is trivial to construct a hashref based on the CPAN config
modules, such as Config::Any.
So, I'm thinking about something like
{ store => 'DBI',
name => 'mymodel',
dsn => 'DBI:mysql:database=rdf',
username => 'dahut',
password => 'Str0ngPa55w0RD'
}
for a MySQL-backed DBI-store.
For a Memory store that loads from a number of resources on startup,
something like:
{ store => 'Memory',
sources => [
{ file => 't/data/basic.trig',
syntax => 'trig',
base => 'http://example.org/' },
{ url => 'http://www.kjetil.kjernsmo.net/foaf',
syntax => 'rdfxml',
graph => 'http://example.org/graphs/foaf-files' },
]
}
and Redland can be done like this:
{ store => 'Redland',
storage_name => 'hashes',
name => 'test',
options => { host=>'localhost',
database=>'testdb',
user=>'testuser' }
}
What do you think about this?
Cheers,
Kjetil
--
Kjetil Kjernsmo
kjetil at kjernsmo.net
http://www.kjetil.kjernsmo.net/
More information about the Dev
mailing list