-
Notifications
You must be signed in to change notification settings - Fork 10
/
cachedump.pl
executable file
·51 lines (37 loc) · 1.07 KB
/
cachedump.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl
#
# Dump the keys of Squeezebox Server'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 Squeezebox Server 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";