line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
############################################################################### |
2
|
|
|
|
|
|
|
## ---------------------------------------------------------------------------- |
3
|
|
|
|
|
|
|
## Scalar helper class. |
4
|
|
|
|
|
|
|
## |
5
|
|
|
|
|
|
|
############################################################################### |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package MCE::Shared::Scalar; |
8
|
|
|
|
|
|
|
|
9
|
15
|
|
|
15
|
|
2494
|
use strict; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
695
|
|
10
|
15
|
|
|
15
|
|
76
|
use warnings; |
|
15
|
|
|
|
|
29
|
|
|
15
|
|
|
|
|
963
|
|
11
|
|
|
|
|
|
|
|
12
|
15
|
|
|
15
|
|
339
|
use 5.010001; |
|
15
|
|
|
|
|
45
|
|
13
|
|
|
|
|
|
|
|
14
|
15
|
|
|
15
|
|
78
|
no warnings qw( threads recursion uninitialized numeric ); |
|
15
|
|
|
|
|
18
|
|
|
15
|
|
|
|
|
1664
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '1.885'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
## no critic (TestingAndDebugging::ProhibitNoStrict) |
19
|
|
|
|
|
|
|
|
20
|
15
|
|
|
15
|
|
91
|
use MCE::Shared::Base (); |
|
15
|
|
|
|
|
54
|
|
|
15
|
|
|
|
|
938
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use overload ( |
23
|
15
|
|
|
|
|
518
|
q("") => \&MCE::Shared::Base::_stringify, |
24
|
|
|
|
|
|
|
q(0+) => \&MCE::Shared::Base::_numify, |
25
|
|
|
|
|
|
|
fallback => 1 |
26
|
15
|
|
|
15
|
|
82
|
); |
|
15
|
|
|
|
|
30
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Based on Tie::StdScalar from Tie::Scalar. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub TIESCALAR { |
31
|
0
|
|
|
0
|
|
|
my $class = shift; |
32
|
0
|
0
|
|
|
|
|
bless \do{ my $o = defined $_[0] ? shift : undef }, $class; |
|
0
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
0
|
|
|
sub STORE { ${ $_[0] } = $_[1] } |
|
0
|
|
|
|
|
|
|
36
|
0
|
|
|
0
|
|
|
sub FETCH { ${ $_[0] } } |
|
0
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
############################################################################### |
39
|
|
|
|
|
|
|
## ---------------------------------------------------------------------------- |
40
|
|
|
|
|
|
|
## Sugar API, mostly resembles https://redis.io/commands#string primitives. |
41
|
|
|
|
|
|
|
## |
42
|
|
|
|
|
|
|
############################################################################### |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# append ( string ) |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub append { |
47
|
0
|
|
0
|
0
|
1
|
|
length( ${ $_[0] } .= $_[1] // '' ); |
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# decr |
51
|
|
|
|
|
|
|
# decrby ( number ) |
52
|
|
|
|
|
|
|
# incr |
53
|
|
|
|
|
|
|
# incrby ( number ) |
54
|
|
|
|
|
|
|
# getdecr |
55
|
|
|
|
|
|
|
# getincr |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
0
|
1
|
|
sub decr { --${ $_[0] } } |
|
0
|
|
|
|
|
|
|
58
|
0
|
|
0
|
0
|
1
|
|
sub decrby { ${ $_[0] } -= $_[1] || 0 } |
|
0
|
|
|
|
|
|
|
59
|
0
|
|
|
0
|
1
|
|
sub incr { ++${ $_[0] } } |
|
0
|
|
|
|
|
|
|
60
|
0
|
|
0
|
0
|
1
|
|
sub incrby { ${ $_[0] } += $_[1] || 0 } |
|
0
|
|
|
|
|
|
|
61
|
0
|
|
0
|
0
|
1
|
|
sub getdecr { ${ $_[0] }-- // 0 } |
|
0
|
|
|
|
|
|
|
62
|
0
|
|
0
|
0
|
1
|
|
sub getincr { ${ $_[0] }++ // 0 } |
|
0
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# getset ( value ) |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub getset { |
67
|
0
|
|
|
0
|
1
|
|
my $old = ${ $_[0] }; |
|
0
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
${ $_[0] } = $_[1]; |
|
0
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$old; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# len ( ) |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub len { |
76
|
0
|
|
|
0
|
1
|
|
length ${ $_[0] }; |
|
0
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
{ |
80
|
15
|
|
|
15
|
|
8921
|
no strict 'refs'; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
1843
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
*{ __PACKAGE__.'::new' } = \&TIESCALAR; |
83
|
|
|
|
|
|
|
*{ __PACKAGE__.'::set' } = \&STORE; |
84
|
|
|
|
|
|
|
*{ __PACKAGE__.'::get' } = \&FETCH; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |