Plugin Directory

Changeset 2015568


Ignore:
Timestamp:
01/19/2019 10:12:34 PM (7 years ago)
Author:
janiko
Message:

data caching added

Location:
zotero-notes/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • zotero-notes/trunk/class.zotero-notes-dataCollector.php

    r2015524 r2015568  
    5757       
    5858        /**
    59          * First, we try with wikipedia Citroid API, but the result may be incomplete...
    60          * However, it's very useful for PDF documents.
     59         * Let's fetch the Zotero reference. If it exists in cache, no need to retrieve it (if not too old).
    6160         */
    6261       
    6362        $curl_url_zotero = self::ZOTERO_API_URL . "/users/" . $zotero_id . "/items/" . $item_id . "?v=" . self::ZOTERO_API_VERSION;
    64         $zotero_response = self::_my_curl($curl_url_zotero, $zotero_key);
     63       
     64        /* Is it in cache? */
     65        $transient_key = $item_id . ":" . $zotero_id;
     66        if ( false === ( $zotero_response = get_transient( $transient_key ) ) ) {
     67            // It wasn't there, so regenerate the data and save the transient
     68            $zotero_response = self::_my_curl($curl_url_zotero, $zotero_key);
     69            set_transient( $transient_key, $zotero_response, 12 * HOUR_IN_SECONDS );
     70        }
    6571
    6672        // Then we parse the response to find the information
     
    9298        curl_setopt($curl, CURLOPT_USERAGENT, filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'));  // TNO
    9399       
    94         curl_setopt($curl, CURLOPT_HTTPHEADER, array("Zotero-API-Key: " . $zotero_key));
     100        curl_setopt($curl, CURLOPT_HTTPHEADER, array("Zotero-API-Key: " . $zotero_key, "Cache-Control: max-age=3600; public"));
    95101       
    96102        $response = curl_exec( $curl );  // TNO
  • zotero-notes/trunk/class.zotero-notes-referencesList.php

    r2015524 r2015568  
    2121     */
    2222     
     23    private $_post_id;
    2324    private $_liste_references = array();
    2425
  • zotero-notes/trunk/readme.txt

    r2015524 r2015568  
    5151== Changelog ==
    5252
     53= 1.0.1 =
     54Some caching added (to prevent too frequent curl calls).
     55
    5356= 1.0.0 =
    5457* First public release
  • zotero-notes/trunk/zotero-notes.php

    r2008431 r2015568  
    1919     */
    2020
    21      
    2221    public function __construct() {
    2322
     
    4645        new zotero_notes_ReferencesList();
    4746    }
     47
     48   
    4849}
    4950
Note: See TracChangeset for help on using the changeset viewer.