line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: /mirror/perl/Data-Throttler-Memcached/trunk/lib/Data/Throttler/Memcached.pm 8774 2007-11-08T09:43:20.728908Z daisuke $ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Copyright (c) 2007 Daisuke Maki |
4
|
|
|
|
|
|
|
# All rights reserved. |
5
|
|
|
|
|
|
|
package Data::Throttler::Memcached; |
6
|
1
|
|
|
1
|
|
49552
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
8
|
1
|
|
|
1
|
|
5
|
use base qw(Data::Throttler); |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
920
|
|
9
|
1
|
|
|
1
|
|
420944
|
use Data::Throttler::BucketChain::Memcached; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.00003'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new |
14
|
|
|
|
|
|
|
{ |
15
|
|
|
|
|
|
|
my $class = shift; |
16
|
|
|
|
|
|
|
my %args = @_; |
17
|
|
|
|
|
|
|
my $empty = sub {}; |
18
|
|
|
|
|
|
|
my $self = bless { |
19
|
|
|
|
|
|
|
lock => $empty, |
20
|
|
|
|
|
|
|
unlock => $empty, |
21
|
|
|
|
|
|
|
db => { chain => {} } |
22
|
|
|
|
|
|
|
}, $class; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$self->{lock}->(); |
25
|
|
|
|
|
|
|
$self->{db}->{chain} = Data::Throttler::BucketChain::Memcached->new( |
26
|
|
|
|
|
|
|
max_items => $args{max_items}, |
27
|
|
|
|
|
|
|
interval => $args{interval}, |
28
|
|
|
|
|
|
|
cache => $args{cache} |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
$self->{unlock}->(); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return $self; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |