SHARE
TWEET

Untitled

a guest Nov 20th, 2015 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getLastValue(itemId){
  2.  
  3.    var cache = CacheService.getPublicCache();
  4.    var cached = cache.get(itemId.toString());
  5.    
  6.    if (cached != null) {
  7.      return cached;
  8.    } else {
  9.    
  10.      var json =ImportJSON("http://services.runescape.com/m=itemdb_rs/api/graph/" + itemId + ".json", "/daily");
  11.      var daily = json[json.length - 1];
  12.  
  13.      cache.put(itemId.toString(), daily[daily.length - 1], 14400); // cache for 4 hours
  14.  
  15.      return daily[daily.length - 1];
  16.    }
  17. }
RAW Paste Data
Top