original_string: function save() {
  
  		if ($this->cacheConf['type'] == 'noop') {
  			// do nothing
  		}
  		else { // non-noop
  
  			$stateCopy = $this->state;
  			$stateCopy['loaded'] = [];
  
  			if ($this->cacheConf['type'] == 'file') {
  				$username = \get_current_user();
  				$cacheDir = realpath($this->syspath.'/'.\trim($this->cacheConf['path'], '\\/'));
  				$cachePath = $cacheDir.'/freia.'.(\php_sapi_name() === 'cli' ? 'cli' : 'server').'.'.$username.'.symbols.json';
  				if ($this->file_exists($cacheDir)) {
  					try {
  						$this->file_put_contents($cachePath, \json_encode($stateCopy, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
  						if ( ! $this->chmod($cachePath, $this->filePermission())) {
  							$this->error_log("Unable to set permissions on cache file: $cachePath");
  						}
  					}
  					catch (\Exception $e) {
  						$this->error_log('Failed to save state to cache file ['.$cachePath.'] Error: '.$e->getMessage());
  					}
  				}
  				else {
  					$this->error_log('Missing cache directory: '.$this->cacheConf['path']);
  				}
  			}
  			else if ($this->cacheConf['type'] == 'memcached') {
  				$mc = $this->memcachedInstance();
  				$success = $mc->set('freia-symbols', $stateCopy, time() + 604800);
  				if ( ! $success) {
  					$this->error_log("Memcached failed to store key freia-symbols, code: ".$mc->getResultCode());
  				}
  			}
  		}
  	}
code: function save() {
  
  		if ($this->cacheConf['type'] == 'noop') {
  			// do nothing
  		}
  		else { // non-noop
  
  			$stateCopy = $this->state;
  			$stateCopy['loaded'] = [];
  
  			if ($this->cacheConf['type'] == 'file') {
  				$username = \get_current_user();
  				$cacheDir = realpath($this->syspath.'/'.\trim($this->cacheConf['path'], '\\/'));
  				$cachePath = $cacheDir.'/freia.'.(\php_sapi_name() === 'cli' ? 'cli' : 'server').'.'.$username.'.symbols.json';
  				if ($this->file_exists($cacheDir)) {
  					try {
  						$this->file_put_contents($cachePath, \json_encode($stateCopy, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
  						if ( ! $this->chmod($cachePath, $this->filePermission())) {
  							$this->error_log("Unable to set permissions on cache file: $cachePath");
  						}
  					}
  					catch (\Exception $e) {
  						$this->error_log('Failed to save state to cache file ['.$cachePath.'] Error: '.$e->getMessage());
  					}
  				}
  				else {
  					$this->error_log('Missing cache directory: '.$this->cacheConf['path']);
  				}
  			}
  			else if ($this->cacheConf['type'] == 'memcached') {
  				$mc = $this->memcachedInstance();
  				$success = $mc->set('freia-symbols', $stateCopy, time() + 604800);
  				if ( ! $success) {
  					$this->error_log("Memcached failed to store key freia-symbols, code: ".$mc->getResultCode());
  				}
  			}
  		}
  	}
code_tokens: function save ( ) { if ( $ this -> cacheConf [ 'type' ] == 'noop' ) { // do nothing } else { // non-noop $ stateCopy = $ this -> state ; $ stateCopy [ 'loaded' ] = [ ] ; if ( $ this -> cacheConf [ 'type' ] == 'file' ) { $ username = \ get_current_user ( ) ; $ cacheDir = realpath ( $ this -> syspath . '/' . \ trim ( $ this -> cacheConf [ 'path' ] , '\\/' ) ) ; $ cachePath = $ cacheDir . '/freia.' . ( \ php_sapi_name ( ) === 'cli' ? 'cli' : 'server' ) . '.' . $ username . '.symbols.json' ; if ( $ this -> file_exists ( $ cacheDir ) ) { try { $ this -> file_put_contents ( $ cachePath , \ json_encode ( $ stateCopy , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) ) ; if ( ! $ this -> chmod ( $ cachePath , $ this -> filePermission ( ) ) ) { $ this -> error_log ( "Unable to set permissions on cache file: $cachePath" ) ; } } catch ( \ Exception $ e ) { $ this -> error_log ( 'Failed to save state to cache file [' . $ cachePath . '] Error: ' . $ e -> getMessage ( ) ) ; } } else { $ this -> error_log ( 'Missing cache directory: ' . $ this -> cacheConf [ 'path' ] ) ; } } else if ( $ this -> cacheConf [ 'type' ] == 'memcached' ) { $ mc = $ this -> memcachedInstance ( ) ; $ success = $ mc -> set ( 'freia-symbols' , $ stateCopy , time ( ) + 604800 ) ; if ( ! $ success ) { $ this -> error_log ( "Memcached failed to store key freia-symbols, code: " . $ mc -> getResultCode ( ) ) ; } } } }
docstring: Save current state to persistent store
docstring_tokens: Save current state to persistent store