RE: [LP8.6.3/IIS] Cache not working? [fixed]

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

RE: [LP8.6.3/IIS] Cache not working? [fixed]

Jon Harris
Hi List

I have realised my mistake here -  I can only cache "html" output, I can't cache variables.

Jon


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Jon Harris
Sent: 19 August 2015 08:53
To: [hidden email]
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 [hidden email] Official list archives available at http://www.lassotalk.com To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

RE: [LP8.6.3/IIS] Cache not working? [fixed]

Rick Draper-2
Can you use a temporary file?

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Jon Harris
Sent: Wednesday, 19 August 2015 6:04 PM
To: [hidden email]
Subject: 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



#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: [LP8.6.3/IIS] Cache not working? [fixed]

Johan Solve
In reply to this post by Jon Harris
The cache.../cache container tag is used to cache html output.
However, you can use cache_store to cache variables and data
structures.


2015-08-19 10:04 GMT+02:00 Jon Harris <[hidden email]>:

> Hi List
>
> I have realised my mistake here -  I can only cache "html" output, I can't cache variables.
>
> Jon
>
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Jon Harris
> Sent: 19 August 2015 08:53
> To: [hidden email]
> 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 [hidden email] Official list archives available at http://www.lassotalk.com To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>   the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>



--
Mvh
Johan Sölve
____________________________________
Montania System AB
Halmstad   Stockholm
http://www.montania.se

Johan Sölve
Mobil +46 709-51 55 70
[hidden email]

Kristinebergsvägen 17, S-302 41 Halmstad, Sweden
Telefon +46 35-136800 |  Fax +46 35-136801

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>