-
Notifications
You must be signed in to change notification settings - Fork 3
/
ttl_test.pm
57 lines (42 loc) · 1.49 KB
/
ttl_test.pm
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
52
53
54
55
56
57
use strict;
use warnings;
use Data::Dumper;
use Cassandra::Simple;
sub println {
print @_, "\n";
}
my ( $keyspace, $column_family ) = qw/simple simple/;
my $conn = Cassandra::Simple->new( keyspace => $keyspace, );
my $not_there =
grep { $_ eq $column_family }[ $conn->list_keyspace_cfs($keyspace) ];
if ($not_there) {
println "Creating $column_family in $keyspace";
$conn->create_column_family( $keyspace, $column_family, 1 );
}
println "\$conn->insert($column_family, 'DyingKey', [ [ 'C1' => 'Dead1' ], [ 'C2' => 'Dead2' ] ], { ttl => 20 } )";
$conn->insert($column_family, 'DyingKey', [ [ 'C1' => 'Dead1' ], [ 'C2' => 'Dead2' ] ], { ttl => 20 } );
println "\$conn->insert($column_family, 'DyingKey', [ [ 'C3' => 'Dead3' ] ], { ttl => 30 })";
$conn->insert($column_family, 'DyingKey', [ [ 'C3' => 'Dead3' ] ], { ttl => 30 });
println "\$conn->get($column_family, 'DyingKey')";
println Dumper $conn->get($column_family, 'DyingKey');
#Expected result: C1, C2 and C3
println "sleep(22)";
for (my $i=22; $i >= 0; $i--){
print "$i . . ";
sleep(1);
}
println "\n";
println "\$conn->get($column_family, 'DyingKey')";
println Dumper $conn->get($column_family, 'DyingKey');
#Expected result: C3
println "sleep(12)";
for (my $i=12; $i >= 0; $i--){
print "$i . . ";
sleep(1);
}
println "\n";
println "\$conn->get($column_family, 'DyingKey')";
println Dumper $conn->get($column_family, 'DyingKey');
#Expected result: none
println "\$conn->remove($column_family)";
println Dumper $conn->remove($column_family);