loader = $loader; $this->helper = $plugin_helper; } /** * If the information is in the cache, then retrieve the information from the cache. * Else get the information by making a GET request. * * @since 1.8.0 * * @param string $key Unique identification of the information. * @param string $url URL for making a request. * @param string $link_code Link Code to be entered in URLS for attribution purposes. * * @return string GET Response. */ public function get( $key, $url ) { $info = $this->lookup( $key ); return $info !== false ? $info : $this->create_cache_entry( $key, $url ); } /** * Lookup in the cache for a particular key. * If the key exists in the cache, the data is return. * Else false is returned. * * @since 1.8.0 * * @param string $key Unique identification of the information. * * @return string Data in the cache. */ protected function lookup( $key ) { return get_transient( $key ); } /** * Load the information with a GET request and save it in the cache. Return the loaded information. * * @since 1.8.0 * * @param string $key Unique identification of the information. * @param string $url URL for making a request. * @param string $link_code Link Code to be entered in URLS for attribution purposes. * * @return string GET Response. */ protected function create_cache_entry( $key, $url ) { $info = $this->loader->load( $url ); set_transient( $key, $info, AALB_CACHE_FOR_MARKETPLACE_CONFIG_TTL ); return $info; } } ?>