Esempio n. 1
0
 public function testIsExists()
 {
     $reply = $this->key->isExists();
     $this->assertFalse($reply);
     $this->key->getRediska()->set($this->key->getName(), 1);
     $reply = $this->key->isExists();
     $this->assertTrue($reply);
 }
Esempio n. 2
0
 public function testGetOrSetValue()
 {
     $provider = new BasicKeyDataProvider();
     $value = $this->key->getOrSetValue($provider)->data;
     $this->assertEquals(123, $value);
     $reply = $this->key->isExists();
     $this->assertTrue($reply);
     $this->assertEquals(123, $this->key->getValue());
     $value = $this->key->getOrSetValue($provider)->getOtherDataForTest();
     $this->assertEquals(123, $value);
     $this->key->delete();
     $value = $this->key->getOrSetValue($provider)->getData();
     $this->assertEquals(123, $value);
     $reply = $this->key->isExists();
     $this->assertTrue($reply);
     $this->assertEquals(123, $this->key->getValue());
     $getOrSetValueObject = $this->key->getOrSetValue($provider);
     $this->assertEquals(123, "{$getOrSetValueObject}");
 }
Esempio n. 3
0
 public function testGetOrSetValue()
 {
     require_once REDISKA_TESTS_PATH . '/classes/BasicKeyDataProvider.php';
     $provider = new BasicKeyDataProvider();
     $value = $this->key->getOrSetValue($provider)->data;
     $this->assertEquals(123, $value);
     $reply = $this->key->isExists();
     $this->assertTrue($reply);
     $this->assertEquals(123, $this->key->getValue());
     $value = $this->key->getOrSetValue($provider)->getOtherDataForTest();
     $this->assertEquals(123, $value);
     $this->key->delete();
     $value = $this->key->getOrSetValue($provider)->getData();
     $this->assertEquals(123, $value);
     $reply = $this->key->isExists();
     $this->assertTrue($reply);
     $this->assertEquals(123, $this->key->getValue());
     $getOrSetValueObject = $this->key->getOrSetValue($provider);
     $this->assertEquals(123, "{$getOrSetValueObject}");
 }
Esempio n. 4
0
 public function get($key)
 {
     $Key = new Rediska_Key($key);
     $Key->setRediska($this->Rediska);
     if (!$Key->isExists()) {
         return false;
     }
     //		try {
     //			return $Key->getValue();
     //		} catch (Exception $exc) {
     //			prd($key);
     //			echo $exc->getTraceAsString();
     //		}
     # @todo
     #$Key->delete();
     return $Key->getValue();
 }
Esempio n. 5
0
 /**
  * Checks whether the client UUID is valid. Returns false, if it is not.
  */
 public static function validateUuid($uuid)
 {
     if (strlen($uuid) != 48 || !self::validateHex($uuid)) {
         return false;
     }
     $uuidKey = new Rediska_Key('uuid_' . $uuid);
     return $uuidKey->isExists();
 }