public function cas($cas_token, $key, $value, $expiration = 0) {
    $key = $this->getPrefixKey($key);
    $request = new MemcacheSetRequest();
    $response = new MemcacheSetResponse();

    $memcache_flag = 0;
    $serialized_value = MemcacheUtils::serializeValue($value, $memcache_flag);

    $item = $request->addItem();
    $item->setKey($key);
    $item->setValue($serialized_value);
    $item->setFlags($memcache_flag);
    $item->setSetPolicy(SetPolicy::CAS);
    $item->setCasId($cas_token);
    $item->setExpirationTime($expiration);

    try {
      ApiProxy::makeSyncCall('memcache', 'Set', $request, $response);
    } catch (Error $e) {
      $this->result_code = self::RES_FAILURE;
      return false;
    }

    switch ($response->getSetStatusList()[0]) {
      case SetStatusCode::STORED:
        $this->result_code = self::RES_SUCCESS;
        return true;
      case SetStatusCode::NOT_STORED:
        $this->result_code = self::RES_NOTSTORED;
        return false;
      case SetStatusCode::EXISTS:
        $this->result_code = self::RES_DATA_EXISTS;
        return false;
      default:
        $this->result_code = self::RES_FAILURE;
        return false;
    }
  }