Friday, April 27, 2012

How to change the cache time based on output result

 I have used the following query to get the same.

Here as you can see i am using XQuery expression at response.

I am comparing the return status with string 'S'


Evaluate XQuery Expression at Response :
(compare($body/get:OutputParameters/get:RETURN_STATUS,'S')*2+1)*60


Here S stands for success message and similarly for error message the  return status will be E.

Now if the return status is S than compare will gives us a result 0

0*2+1=1

and then we are multiplying it with 60 to define 60 seconds as cache time to live.

Now in case of error The return status will be E so the compare statement will give us a value of -1

Now the total value of expression will be

-1*2+1=-1

So overall value will be -60.

When the value is negative in xquery the cache is not stored.

So we have achieved the dual functionality of changing the time to live for success process and at the same time not caching the data for error message.

No comments: