original_string: public function set($key, $content, $expiry = 0)
      {
          $cacheObj = new \stdClass();
  
          if (!is_string($content)) {
              $content = serialize($content);
          }
  
          $cacheObj->content = $content;
  
          if (!$expiry) {
              // If no expiry specified, set to 'Never' expire timestamp (+10 years)
              $cacheObj->expiryTimestamp = time() + 315360000;
          } elseif ($expiry > 2592000) {
              // For value greater than 30 days, interpret as timestamp
              $cacheObj->expiryTimestamp = $expiry;
          } else {
              // Else, interpret as number of seconds
              $cacheObj->expiryTimestamp = time() + $expiry;
          }
  
          // Do not save if cache has already expired
          if ($cacheObj->expiryTimestamp < time()) {
              $this->delete($key);
  
              return false;
          }
  
          $cacheFileData = json_encode($cacheObj);
  
          if ($this->config['gzipCompression']) {
              $cacheFileData = gzcompress($cacheFileData);
          }
  
          $filePath = $this->getFilePathFromKey($key);
          $result = file_put_contents($filePath, $cacheFileData);
  
          return $result ? true : false;
      }
code: public function set($key, $content, $expiry = 0)
      {
          $cacheObj = new \stdClass();
  
          if (!is_string($content)) {
              $content = serialize($content);
          }
  
          $cacheObj->content = $content;
  
          if (!$expiry) {
              // If no expiry specified, set to 'Never' expire timestamp (+10 years)
              $cacheObj->expiryTimestamp = time() + 315360000;
          } elseif ($expiry > 2592000) {
              // For value greater than 30 days, interpret as timestamp
              $cacheObj->expiryTimestamp = $expiry;
          } else {
              // Else, interpret as number of seconds
              $cacheObj->expiryTimestamp = time() + $expiry;
          }
  
          // Do not save if cache has already expired
          if ($cacheObj->expiryTimestamp < time()) {
              $this->delete($key);
  
              return false;
          }
  
          $cacheFileData = json_encode($cacheObj);
  
          if ($this->config['gzipCompression']) {
              $cacheFileData = gzcompress($cacheFileData);
          }
  
          $filePath = $this->getFilePathFromKey($key);
          $result = file_put_contents($filePath, $cacheFileData);
  
          return $result ? true : false;
      }
code_tokens: public function set ( $ key , $ content , $ expiry = 0 ) { $ cacheObj = new \ stdClass ( ) ; if ( ! is_string ( $ content ) ) { $ content = serialize ( $ content ) ; } $ cacheObj -> content = $ content ; if ( ! $ expiry ) { // If no expiry specified, set to 'Never' expire timestamp (+10 years) $ cacheObj -> expiryTimestamp = time ( ) + 315360000 ; } elseif ( $ expiry > 2592000 ) { // For value greater than 30 days, interpret as timestamp $ cacheObj -> expiryTimestamp = $ expiry ; } else { // Else, interpret as number of seconds $ cacheObj -> expiryTimestamp = time ( ) + $ expiry ; } // Do not save if cache has already expired if ( $ cacheObj -> expiryTimestamp < time ( ) ) { $ this -> delete ( $ key ) ; return false ; } $ cacheFileData = json_encode ( $ cacheObj ) ; if ( $ this -> config [ 'gzipCompression' ] ) { $ cacheFileData = gzcompress ( $ cacheFileData ) ; } $ filePath = $ this -> getFilePathFromKey ( $ key ) ; $ result = file_put_contents ( $ filePath , $ cacheFileData ) ; return $ result ? true : false ; }
docstring: Sets an item in the cache.
  
  @param mixed $key
  @param mixed $content
  @param int   $expiry
  
  @return bool
docstring_tokens: Sets an item in the cache .