Aug 19, 2015; 08:04
Jon Harris
RE: [LP8.6.3/IIS] Cache not working? [fixed]
Hi List
I have realised my mistake here - I can only cache "html" output, I can't cache variables.
Jon
-----Original Message-----
From: lasso-bounces@lists.lassosoft.com [mailto:lasso-bounces@lists.lassosoft.com] On Behalf Of Jon Harris
Sent: 19 August 2015 08:53
To: lasso@lists.lassosoft.com
Subject: [LP8.6.3/IIS] Cache not working?
Hi
I am working on a ecommerce site where we get stock levels via a web service call. I am using include_URL, posting the parameters and getting XML back for each product code and current stock level. The data is not that dynamic, so I want to speed things up by not having to get the data each time a product page is displayed. The webservice does not allow the product code to be passed, it will only return all products.
On the product page, an ajax call gets the current stock level and displays it, a couple of secs after the page loads. The actual code is working fine. The ajax page looks like this:
// getstocklevel.lasso
var('pcode') = action_param('pcode') ;
Cache(-Name='ProductCache', -expires=600) ;
var('theproducts') = (map) ;
var('endpoint') = "http://<the_endpoint>" ;
var('service') = "/webservices/GETALLSTORESTOCK" ;
var('params') = array('SinceDate' ='2015-01-01T00:00:00', 'User' = '', 'Password' = '') ;
var('rawdata') = string(include_url($endpoint + $service, -postPARAMS=$params)) ;
// cast to xml
var('xmldata') = xml( var('rawdata') ) ;
// xpaths for each field
var('xproductsno') = '/DataSet/StoreStock[*]/ProductNo' ;
var('xquantities') = '/DataSet/StoreStock[*]/Quantity' ;
var('productnos') = XML_Extract(-XML=$xmldata, $xproductsno) ;
var('quantities') = XML_Extract(-XML=$xmldata, $xquantities) ;
iterate($productnos, var('xthisProductNo') ) ;
var('thisProductNo') = var('xthisproductNo')->contents ;
var('thisProductNo')->trim ;
var('thisQuantity') = var('quantities')->get(loop_count)->contents ;
// add to the map
$theproducts->insert($thisproductno = $thisQuantity) ; /iterate ;
/cache ;
var('returnVal') = $theproducts->find($pcode) ;
if($returnVal) ;
$returnVal ;
else ;
"ERROR" ;
/if ;
This code works once with the cache tags, then fails. And without the cache tags its fine. Checking in lassoadmin the cache, reads:
ProductCache_global
Value Size 0 Chars
Value Type String
Store Count 1
Fetch Count 1
Efficiency 0%
In other words, the code fails because the cache is empty and returns nothing.
(I tried changing from site to global caches, but no difference)
My alternative method is to import the data into a mysql table and run a scheduled task to keep reading in the data, but I would like to understand what is going on here.
Any pointers appreciated.
Jon Harris
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso Lasso@lists.lassosoft.com Official list archives available at http://www.lassotalk.com To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso Lasso@lists.lassosoft.com
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>
Aug 19, 2015; 19:59
Rick Draper
RE: [LP8.6.3/IIS] Cache not working? [fixed]
Aug 19, 2015; 13:20
Johan Solve
Re: [LP8.6.3/IIS] Cache not working? [fixed]