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
|
|
2165
|
use strict; |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
917
|
|
10
|
15
|
|
|
15
|
|
95
|
use warnings; |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
1155
|
|
11
|
|
|
|
|
|
|
|
12
|
15
|
|
|
15
|
|
701
|
use 5.010001; |
|
15
|
|
|
|
|
63
|
|
13
|
|
|
|
|
|
|
|
14
|
15
|
|
|
15
|
|
226
|
no warnings qw( threads recursion uninitialized numeric ); |
|
15
|
|
|
|
|
209
|
|
|
15
|
|
|
|
|
1831
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '1.886'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
## no critic (TestingAndDebugging::ProhibitNoStrict) |
19
|
|
|
|
|
|
|
|
20
|
15
|
|
|
15
|
|
108
|
use MCE::Shared::Base (); |
|
15
|
|
|
|
|
132
|
|
|
15
|
|
|
|
|
1220
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use overload ( |
23
|
15
|
|
|
|
|
535
|
q("") => \&MCE::Shared::Base::_stringify, |
24
|
|
|
|
|
|
|
q(0+) => \&MCE::Shared::Base::_numify, |
25
|
|
|
|
|
|
|
fallback => 1 |
26
|
15
|
|
|
15
|
|
93
|
); |
|
15
|
|
|
|
|
56
|
|
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
|
|
9938
|
no strict 'refs'; |
|
15
|
|
|
|
|
69
|
|
|
15
|
|
|
|
|
1938
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
*{ __PACKAGE__.'::new' } = \&TIESCALAR; |
83
|
|
|
|
|
|
|
*{ __PACKAGE__.'::set' } = \&STORE; |
84
|
|
|
|
|
|
|
*{ __PACKAGE__.'::get' } = \&FETCH; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |