Hi All,
I am new to webMethods and I have requirement to use cache results from database.
I am running a query on database and get some lookupdata from there. I want to cache that data so that it does not go to database every time i lookup for a value. I have created a startup service to fetch the data.
Questions:
- Do I need to run a loop over the results of the query to put every value in cache?
- If I need to search a value based on multiple columns how do we do that? Like suppose lookp_type and code1 is the criteria to get the value1. How do I pass 2 values as key to pub.chache.get?
any help to this is much appreciated.
Thanks
Hi Sharad,
I would suggest to revise your code.
Modify the adapter service to lookup one value instead of looking up all values.
Set this service to “Caching”. Depending on how static your data is, choose the cache timeout wisely.
In your regular code whenever you have to lookup a value from the database, call the modified adapter service as a transformer.
This makes sure that only the relevant pipeline data for this service is cached.
By doing so the database will be called one time per key/value pair as long as the key is in the cache afterwards.
When the cache expires the database will be called again to refresh the cache.
Regards,
Holger