@@ 78-90 (lines=13) @@ | ||
75 | * @param mixed $appId |
|
76 | * @return void |
|
77 | */ |
|
78 | public function connection($appId) |
|
79 | { |
|
80 | $currentConnectionCount = $this->ensureAppIsSet($appId) |
|
81 | ->hincrby($this->getHash($appId), 'current_connection_count', 1); |
|
82 | ||
83 | $currentPeakConnectionCount = $this->redis->hget($this->getHash($appId), 'peak_connection_count'); |
|
84 | ||
85 | $peakConnectionCount = is_null($currentPeakConnectionCount) |
|
86 | ? $currentConnectionCount |
|
87 | : max($currentPeakConnectionCount, $currentConnectionCount); |
|
88 | ||
89 | $this->redis->hset($this->getHash($appId), 'peak_connection_count', $peakConnectionCount); |
|
90 | } |
|
91 | ||
92 | /** |
|
93 | * Handle disconnections. |
|
@@ 98-110 (lines=13) @@ | ||
95 | * @param mixed $appId |
|
96 | * @return void |
|
97 | */ |
|
98 | public function disconnection($appId) |
|
99 | { |
|
100 | $currentConnectionCount = $this->ensureAppIsSet($appId) |
|
101 | ->hincrby($this->getHash($appId), 'current_connection_count', -1); |
|
102 | ||
103 | $currentPeakConnectionCount = $this->redis->hget($this->getHash($appId), 'peak_connection_count'); |
|
104 | ||
105 | $peakConnectionCount = is_null($currentPeakConnectionCount) |
|
106 | ? $currentConnectionCount |
|
107 | : max($currentPeakConnectionCount, $currentConnectionCount); |
|
108 | ||
109 | $this->redis->hset($this->getHash($appId), 'peak_connection_count', $peakConnectionCount); |
|
110 | } |
|
111 | ||
112 | /** |
|
113 | * Save all the stored statistics. |