|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- /**
- * Created by PhpStorm.
- * User: wangxj
- * Date: 2017/1/17
- * Time: 19:08
- */
-
- namespace common\components;
-
- use yii\caching\MemCache;
-
- class zMemcache extends MemCache
- {
- public $encrypt = true;
-
- public function get($key)
- {
- if ($this->encrypt == true) {
- $key = $this->buildKey($key);
- $value = $this->getValue($key);
- if ($value === false || $this->serializer === false) {
- return $value;
- } elseif ($this->serializer === null) {
- $value = unserialize($value);
- } else {
- $value = call_user_func($this->serializer[1], $value);
- }
- if (is_array($value) && !($value[1] instanceof Dependency && $value[1]->getHasChanged($this))) {
- return $value[0];
- } else {
- return false;
- }
- } else {
- $value = $this->getValue($key);
- if ($value !== false) {
- return $value;
- } else {
- return false;
- }
-
- }
- }
-
- public function set($key, $value, $duration = 0, $dependency = null)
- {
- if ($this->encrypt === true) {
- return parent::set($key, $value, $duration = 0, $dependency = null);
- } else {
- return $this->setValue($key, $value, $duration);
- }
- }
- // protected function flushValues(){
- // parent::flushValues();
- // }
- // protected function getValue($key){
- // parent::getValue($key);
- // }
- // protected function setValue($key, $value, $duration){
- // parent::setValue($key, $value, $duration);
- // }
- // protected function addValue($key, $value, $duration){
- // parent::addValue($key, $value, $duration);
- // }
- // protected function deleteValue($key){
- // parent::deleteValue($key);
- // }
- }
|