/** * Get the current RSA public key for the LaunchKey API * * @return string */ protected function getPublicKey() { $response = null; $publicKey = null; try { $publicKey = $this->cache->get(static::CACHE_KEY_PUBLIC_KEY); } catch (\Exception $e) { $this->errorLog("An error occurred on a cache get", array("key" => static::CACHE_KEY_PUBLIC_KEY, "Exception" => $e)); } if ($publicKey) { $this->debugLog("Public key cache hit", array("key" => static::CACHE_KEY_PUBLIC_KEY)); } else { $this->debugLog("Public key cache miss", array("key" => static::CACHE_KEY_PUBLIC_KEY)); $response = $this->ping(); $publicKey = $response->getPublicKey(); try { $this->cache->set(static::CACHE_KEY_PUBLIC_KEY, $publicKey, $this->publicKeyTTL); $this->debugLog("Public key saved to cache"); } catch (\Exception $e) { $this->errorLog("An error occurred on a cache set", array("key" => static::CACHE_KEY_PUBLIC_KEY, "value" => $publicKey, "Exception" => $e)); } } return $publicKey; }
public function testSetOverridesExistingValue() { $this->cache->set("any key", "value", 999999999); $this->cache->set("any key", "other value", 999999999); $this->assertEquals("other value", $this->cache->get("any key")); }