ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL Cache

Post new topic  Reply to topic
 ESQL Cache « View previous topic :: View next topic » 
Author Message
priyesh
PostPosted: Thu Jul 09, 2015 10:44 pm    Post subject: ESQL Cache Reply with quote

Newbie

Joined: 11 Jun 2015
Posts: 4

Hi All,

I got a scenario like we can use Shared variables as bellow...

CREATE PROCEDURE getCity_v02 (IN airportCode CHARACTER) RETURNS CHARACTER
BEGIN
-- v02: "ESQL" cache
-- PERFORMANCE TEST ONLY! No ATOMIC blocks.
-- Do not use if Additional Instances > 0.
IF FIELDNAME(CACHE.*[1]) IS NULL THEN
-- load the cache
DECLARE TEMPCACHE ROW;
SET TEMPCACHE.AIRPORT[] = SELECT A.CODE, A.CITY
FROM Database.AIRPORTS AS A;
FOR cacheline AS TEMPCACHE.AIRPORT[] DO
CREATE LASTCHILD OF CACHE NAME cacheline.CODE
VALUE cacheline.CITY;

END FOR;
END IF;
RETURN CACHE.{airportCode};
END;


..............................................

But here I want to put a record as value in place of above statement in bold as I have to store complete records of database . Can I ?....

If possible then please guide me...

Thanks
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Jul 10, 2015 4:14 am    Post subject: Re: ESQL Cache Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

priyesh wrote:
But here I want to put a record as value in place of above statement in bold as I have to store complete records of database . Can I ?....


Yes, you can insert a row into a database from ESQL.

priyesh wrote:
If possible then please guide me...


I'd consider the INSERT statement.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
priyesh
PostPosted: Fri Jul 10, 2015 5:51 am    Post subject: Reply with quote

Newbie

Joined: 11 Jun 2015
Posts: 4

Sorry Vitor but I want to store in chache not in database

My task is to retrieve the records from database and store it in chache.
Quote:

CREATE LASTCHILD OF CACHE NAME cacheline.CODE
VALUE cacheline.CITY;



I want to store a record as key and value pair , taking primary key value as key and complete record as value

so can I ???

Thanks..!!!!!!
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Jul 10, 2015 6:06 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

priyesh wrote:
Sorry Vitor but I want to store in chache not in database


Ah, I was confused by your reference to Shared Variables and reading your post on only 1 cup of coffee. My bad.

Yes, you can store key value pairs in the IIB Global Cache. The cache is only accessible from Java so you'll need to write a couple of Java methods to store and retrieve the values (and this Java is so simple even I've managed to do it!) and then reference the Java from the ESQL as usual.

Works very well.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Fri Jul 10, 2015 6:20 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Vitor wrote:

Yes, you can store key value pairs in the IIB Global Cache. The cache is only accessible from Java so you'll need to write a couple of Java methods to store and retrieve the values (and this Java is so simple even I've managed to do it!) and then reference the Java from the ESQL as usual.

Works very well.


The searching for data in the Global Cache (As supplied with IIB) is IMHO its big Achillies heel.
I did a POC where I loaded up the cache with a number of DB tables that contained almost static data (such as Component Suppliers) but the overhead of searching for one supplier was far, far worse than getting it with a DB table read (without locks).
I'm yet to be convinced that the Global Cache is worth using but your application might lead to different results.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Jul 10, 2015 6:43 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

smdavies99 wrote:
I'm yet to be convinced that the Global Cache is worth using but your application might lead to different results.


To be clear, when I said "works very well" I meant having to drop into Java from ESQL to access the cache.

I'm sure that there are any number of use cases where a DB lookup remains preferable to using the cache, especially when the DB itself is caching the data (e.g. where you repeatedly read the same tables of static data).

Where we've found it useful is to store things like session ids and status data so as to facilitate breaking synchronous calls into asynchronous. You could of course use a DB for this, but the cache is convenient, self cleaning (with the time to live set appropriately) and doesn't require huge numbers of database request forms.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
maurito
PostPosted: Mon Jul 13, 2015 12:32 am    Post subject: Reply with quote

Partisan

Joined: 17 Apr 2014
Posts: 358

http://www.ibm.com/developerworks/websphere/library/techarticles/1405_dunn/1405_dunn.html

you will need to add atomic blocks to single thread when loading the cache.
Back to top
View user's profile Send private message
lfrestrepog
PostPosted: Wed Jul 15, 2015 2:38 am    Post subject: Reply with quote

Novice

Joined: 08 Jul 2014
Posts: 22

Hi...

You can also add the whole cacheline to the cache, something like this:

Code:

CREATE PROCEDURE getCity_v02 (IN airportCode CHARACTER) RETURNS CHARACTER
BEGIN
   -- v02: "ESQL" cache
   -- PERFORMANCE TEST ONLY! No ATOMIC blocks.
   -- Do not use if Additional Instances > 0.
   IF FIELDNAME(CACHE.*[1]) IS NULL THEN
      -- load the cache
      DECLARE TEMPCACHE ROW;
      SET TEMPCACHE.AIRPORT[] = SELECT A.CODE, A.CITY FROM Database.AIRPORTS AS A;
      FOR cacheline AS TEMPCACHE.AIRPORT[] DO
         CREATE LASTCHILD OF CACHE FROM cacheline;
      END FOR;
   END IF;
   RETURN CACHE.{airportCode};
END;


Haven't tried myself, but I believe it should work just fine.
_________________
--
Luis Fernando Restrepo Gutiérrez
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL Cache
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.