[Slim-Checkins] r10124 - /branches/6.5/tools/cachedump.pl

andy at svn.slimdevices.com andy at svn.slimdevices.com
Sun Oct 1 10:24:33 PDT 2006


Author: andy
Date: Sun Oct  1 10:24:31 2006
New Revision: 10124

URL: http://svn.slimdevices.com?rev=10124&view=rev
Log:
Script to dump all of the FileCache keys

Added:
    branches/6.5/tools/cachedump.pl   (with props)

Added: branches/6.5/tools/cachedump.pl
URL: http://svn.slimdevices.com/branches/6.5/tools/cachedump.pl?rev=10124&view=auto
==============================================================================
--- branches/6.5/tools/cachedump.pl (added)
+++ branches/6.5/tools/cachedump.pl Sun Oct  1 10:24:31 2006
@@ -1,0 +1,51 @@
+#!/usr/bin/perl
+#
+# Dump the keys of SlimServer's FileCache to a text file
+#
+
+$| = 1;
+
+use strict;
+use warnings;
+
+use Cache::FileCache;
+use File::Spec::Functions qw(catdir);
+use Storable qw(nfreeze);
+
+my $cacheDir = shift || die qq{
+Please specify the path to your SlimServer Cache directory.
+
+Examples: 
+  Win: C:/Program Files/SlimServer/server/Cache
+  Mac: ~/Library/Caches/SlimServer
+
+};
+
+if ( !-d catdir($cacheDir, 'FileCache') ) {
+	die "Directory $cacheDir does not seem to contain a FileCache directory.\n";
+}
+
+my $cache = Cache::FileCache->new( {
+	namespace           => 'FileCache',
+	cache_root          => $cacheDir,
+	directory_umask     => umask(),
+	auto_purge_interval => '1 hour',
+} );
+
+print "Writing cache keys to file: cachedump.txt...\n";
+
+open my $fh, '>', 'cachedump.txt';
+
+my $count = 0;
+
+for my $key ( $cache->get_keys() ) {
+	if ( my $data = $cache->get($key) ) {
+		my $size = ( ref $data ) ? length( nfreeze($data) ) : length($data);
+		print $fh sprintf( "%8d   %s\n", $size, $key );
+		$count++;
+	}
+}
+
+close $fh;
+
+print "Wrote $count keys to cachedump.txt\n";

Propchange: branches/6.5/tools/cachedump.pl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: branches/6.5/tools/cachedump.pl
------------------------------------------------------------------------------
    svn:executable = *

Propchange: branches/6.5/tools/cachedump.pl
------------------------------------------------------------------------------
    svn:keywords = Id Author LastChangedDate LastChangedBy



More information about the checkins mailing list