[Catalyst] using a persistent hash in a model
Jonathan Rockway
jon at jrock.us
Tue Jul 10 08:10:30 GMT 2007
On Saturday 07 July 2007 10:59:27 am Perrin Harkins wrote:
> On 7/7/07, Daniel McBrearty <danielmcbrearty at gmail.com> wrote:
> > Is there any easy way to keep some ad-hoc persistent data out of the
> > database?
>
> Sure. Most of them are either lossy or tricky to use, and tend to be
> poor for concurrent reading/writing.
>
> The obvious options are:
> - BerkeleyDB. Fast, but limited to one machine, and tricky to get
> right because of insufficient docs for the advanced locking features.
> Still, a good bet.
BerkeleyDB has an RPC layer for talking to remote clients. I find the docs
sufficient:
http://www.oracle.com/technology/documentation/berkeley-db/db/gsg/C/index.html
The C API is exactly the same as the Perl API. (Which sucks. But at least
there are no surprises.)
> - Cache::FastMmap. Fast, but lossy. Will silently drop your data if
> you go over the limit you set. Limited to one machine.
> - Cache::Memcached. Fast (although much slower than BerkeleyDB or
> Cache::FastMmap), but lossy. Silently drops data if you go over the
> limit you set. Loses everything if the daemon is stopped for any
> reason. Works for a cluster though.
>
> None of these have the same locking capabilities that a database does,
I don't think the word "database" implies anything about locking (or
relations, or ACID)...
> i.e. writers block readers and there's no easy way to do pessimistic
> locking. (I think BerkeleyDB supports pessimistic locking, but I
> can't remember for sure.)
BerkeleyDB locking is pretty flexible. The transaction system supports all
the isolation levels that you would expect. Rather than worrying about
locks, I would just pick the isolation level I need and let the DBMS figure
it out.
> If you already have a database, using it will be easier than getting
> any of these right.
Agreed. Session::Store::DBIC just Storables a hash into a table. Querying
the individual fields is impossible, but nobody wants to do that anyway.
--
package JAPH;use Catalyst qw/-Debug/;($;=JAPH)->config(name => do {
$,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //,
";$;"]->[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;->setup;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part.
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070710/5f0f35a8/attachment-0001.pgp
More information about the Catalyst
mailing list