Exemple #1
0
 /**
  * Task of this constructor is to check, whether all necessary properties are set in data storage,
  * (if not - set them). Properties should be specific for this current user
  * (initially they default to those of default user)
  */
 public function __construct($pwd)
 {
     parent::__construct();
     if (is_string($pwd) && !empty($pwd)) {
         $this->userPwd = $pwd;
     }
     /// Now we should check, if userdata already exists in Redis. If not - write it there
     $redisDataProvider = new RedisDataProvider($this);
     $existsMapper = new RedisExistsMapper($this->userPwd . '_' . 'init');
     $val = $redisDataProvider->exists($existsMapper);
     if (1 !== intval($val)) {
         /// write client data
     }
 }
Exemple #2
0
 /**
  * getter checks TTL of data and retrieves it from data storage
  * We try to find user-specific key in DataProvider, if none - try to find key for default user in DataProvider,
  * if none - try to read protected properties, if none - throw exception
  * @param string $key key of data to retrieve (key does not contain userPwd prefix)
  * @return mixed value of a key or null
  */
 public function __get($key)
 {
     if ($this->getRedis()->exists($key)) {
     }
     $redisDataProvider = new RedisDataProvider($this);
     $existsMapper = new RedisExistsMapper($key);
     $val = $redisDataProvider->exists($existsMapper);
     if (1 !== intval($val)) {
         $res = null;
     } else {
         $getMapper = new RedisGetMapper($key);
         $res = $redisDataProvider->get($getMapper);
     }
     return $res;
 }