On Dec 29, 2007, at 12:47 AM, Peter Edwards wrote:
I'd think twice about mastering your images in the database.
It depends on data volumes and number of simultaneous accesses, but the easiest is to keep them in a directory hierarchy under Unix with a normal backup to protect them, running an overnight resynchronization job to check
that the database index matches the file system.
It's faster to have a spread of files across directories, so take an MD5 of the record id and split on every 3 characters to give the directory path:
my $imageid = 12345;
my $fullid = sprintf("%012i", $imageid);
my $md5 = md5_hex($fullid);
my @dirs = ($md5 =~ /^(...)(...)(...)/);
my $file = Path::Class::File->new(@dirs, $fullid);
(thanks to mst for that idea)

I like that. I've done similar stuff for archiving images outside a DB before; instead indexing them alphabetically by groups. Don't know what's enamored me of the DB back-up plan. I think I'm off the kick though.

I was going to organize directories by user-id but the md5 idea is better if the store gets huge.

Thanks!
-Ashley

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]

Reply via email to