@@ -74,8 +74,9 @@ public function write($key, $value, $duration) {
7474 if ($ duration ) {
7575 $ expires = time () + $ duration ;
7676 }
77- $ this ->_apcCall ('store ' , $ key . '_expires ' , $ expires , $ duration );
78- return $ this ->_apcCall ('store ' , $ key , $ value , $ duration );
77+ $ func = $ this ->_apcExtension . '_store ' ;
78+ $ func ($ key . '_expires ' , $ expires , $ duration );
79+ return $ func ($ key , $ value , $ duration );
7980 }
8081
8182/**
@@ -86,11 +87,12 @@ public function write($key, $value, $duration) {
8687 */
8788 public function read ($ key ) {
8889 $ time = time ();
89- $ cachetime = (int )$ this ->_apcCall ('fetch ' , $ key . '_expires ' );
90+ $ func = $ this ->_apcExtension . '_fetch ' ;
91+ $ cachetime = (int )$ func ($ key . '_expires ' );
9092 if ($ cachetime !== 0 && ($ cachetime < $ time || ($ time + $ this ->settings ['duration ' ]) < $ cachetime )) {
9193 return false ;
9294 }
93- return $ this -> _apcCall ( ' fetch ' , $ key );
95+ return $ func ( $ key );
9496 }
9597
9698/**
@@ -101,7 +103,8 @@ public function read($key) {
101103 * @return New incremented value, false otherwise
102104 */
103105 public function increment ($ key , $ offset = 1 ) {
104- return $ this ->_apcCall ('inc ' , $ key , $ offset );
106+ $ func = $ this ->_apcExtension . '_inc ' ;
107+ return $ func ($ key , $ offset );
105108 }
106109
107110/**
@@ -112,7 +115,8 @@ public function increment($key, $offset = 1) {
112115 * @return New decremented value, false otherwise
113116 */
114117 public function decrement ($ key , $ offset = 1 ) {
115- return $ this ->_apcCall ('dec ' , $ key , $ offset );
118+ $ func = $ this ->_apcExtension . '_dec ' ;
119+ return $ func ($ key , $ offset );
116120 }
117121
118122/**
@@ -122,7 +126,8 @@ public function decrement($key, $offset = 1) {
122126 * @return bool True if the value was successfully deleted, false if it didn't exist or couldn't be removed
123127 */
124128 public function delete ($ key ) {
125- return $ this ->_apcCall ('delete ' , $ key );
129+ $ func = $ this ->_apcExtension . '_delete ' ;
130+ return $ func ($ key );
126131 }
127132
128133/**
@@ -136,19 +141,20 @@ public function clear($check) {
136141 if ($ check ) {
137142 return true ;
138143 }
144+ $ func = $ this ->_apcExtension . '_delete ' ;
139145 if (class_exists ('APCIterator ' , false )) {
140146 $ iterator = new APCIterator (
141147 'user ' ,
142148 '/^ ' . preg_quote ($ this ->settings ['prefix ' ], '/ ' ) . '/ ' ,
143149 APC_ITER_NONE
144150 );
145- $ this -> _apcCall ( ' delete ' , $ iterator );
151+ $ func ( $ iterator );
146152 return true ;
147153 }
148154 $ cache = $ this ->_apcExtension === 'apc ' ? apc_cache_info ('user ' ) : apcu_cache_info ();
149155 foreach ($ cache ['cache_list ' ] as $ key ) {
150156 if (strpos ($ key ['info ' ], $ this ->settings ['prefix ' ]) === 0 ) {
151- $ this -> _apcCall ( ' delete ' , $ key ['info ' ]);
157+ $ func ( $ key ['info ' ]);
152158 }
153159 }
154160 return true ;
@@ -168,11 +174,13 @@ public function groups() {
168174 }
169175 }
170176
171- $ groups = $ this ->_apcCall ('fetch ' , $ this ->_compiledGroupNames );
177+ $ fetchFunc = $ this ->_apcExtension . '_fetch ' ;
178+ $ storeFunc = $ this ->_apcExtension . '_store ' ;
179+ $ groups = $ fetchFunc ($ this ->_compiledGroupNames );
172180 if (count ($ groups ) !== count ($ this ->settings ['groups ' ])) {
173181 foreach ($ this ->_compiledGroupNames as $ group ) {
174182 if (!isset ($ groups [$ group ])) {
175- $ this -> _apcCall ( ' store ' , $ group , 1 );
183+ $ storeFunc ( $ group , 1 );
176184 $ groups [$ group ] = 1 ;
177185 }
178186 }
@@ -195,7 +203,7 @@ public function groups() {
195203 * @return bool success
196204 */
197205 public function clearGroup ($ group ) {
198- $ func = function_exists ( ' apc_inc ' ) ? ' apc_inc ' : ' apcu_inc ' ;
206+ $ func = $ this -> _apcExtension . ' _inc ' ;
199207 $ func ($ this ->settings ['prefix ' ] . $ group , 1 , $ success );
200208 return $ success ;
201209 }
@@ -215,18 +223,8 @@ public function add($key, $value, $duration) {
215223 if ($ duration ) {
216224 $ expires = time () + $ duration ;
217225 }
218- $ this ->_apcCall ('add ' , $ key . '_expires ' , $ expires , $ duration );
219- return $ this ->_apcCall ('add ' , $ key , $ value , $ duration );
220- }
221-
222- /**
223- * Call APC(u) function
224- *
225- * @return mixed
226- */
227- protected function _apcCall () {
228- $ params = func_get_args ();
229- $ func = $ this ->_apcExtension . '_ ' . array_shift ($ params );
230- return call_user_func_array ($ func , $ params );
226+ $ func = $ this ->_apcExtension . '_add ' ;
227+ $ func ($ key . '_expires ' , $ expires , $ duration );
228+ return $ func ($ key , $ value , $ duration );
231229 }
232230}
0 commit comments