You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Emmanuele De Andreis <ma...@gmail.com> on 2005/09/25 00:13:59 UTC

Multiple cache and invalidation

HI all,
I have  2 sqlmaps that use LRU cache.

Now sqlmap1 work fine.
Cache is used for SELECT and invalidated on INSERT, UPDATE, DELETE

The sqlmap2 should be cached too but since uses an inner join with
table in sql map1 too should be invaldated when sqlmap1 is INSERT,
UPDATE, DELETE

So how I can Invalidate a cache in one sqlmap from another sql map?
Is there a way to refer to a differente map?
Is there a way to actually define all caches in a separate config file?

I'm using SVN code and Vstudio 2005

Thanks

Manu

Re: Multiple cache and invalidation

Posted by Emmanuele De Andreis <ma...@gmail.com>.
I found a property that fixes this.
<setting useStatementNamespaces="true"/>
in settings in SqlMap.Config

On 9/25/05, Emmanuele De Andreis <ma...@gmail.com> wrote:
> Thanks it works perfectly.
> I have one more question on namespaces.
>
> My sqlmap1 has namespace "Name", so I first assumed that any SELECT
> will be combined to have it.
> eg: a select like:
> <select id="Select" ...
> is inedeed recognized
> <select id="Name.Select"
> but this thorw an error on second Namemap, that complaints the select
> id is already in use.
> On the other side i have added the CacheModel namespace
> cacheModel="CacheModels.NameCache" and this seems to be combined
> automatically.
>
> My cachemodel map is indeed:
> <sqlMap
>        namespace="CacheModels"
>        xmlns="http://ibatis.apache.org/mapping"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >
>        <cacheModels>
>                <cacheModel id="NameCache" implementation="LRU">
>
> Why on cache namespace is added and on select is not added?
> Thanks
>
> Manu
>
> On 9/25/05, Ron Grabowski <ro...@yahoo.com> wrote:
> > To reference a cache model or a statement in another sqlMap file, turn
> > on namespaces and use the full namespace of the item.
> >
> > The code in SVN allows a sqlMap to contain just a cacheModels node:
> >
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <sqlMap namespace="CacheModels"
> > xmlns="http://ibatis.apache.org/mapping"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> >  <cacheModels>
> >  <cacheModel id="UserCache" implementation="MEMORY">
> >   <property name="Type" value="Strong" />
> >   <flushInterval hours="2" />
> >   <flushOnExecute statement="User.Insert" />
> >   <flushOnExecute statement="User.Update" />
> >   <flushOnExecute statement="User.Delete" />
> >  </cacheModel>
> >  </cacheModels>
> > </sqlMap>
> >
> > The code in SVN also delays associating cacheModels with statements
> > until all statements have been processed so you can include your
> > cacheModel sqlMap file before or after your other sqlMap files.
> >
> > --- Emmanuele De Andreis <ma...@gmail.com> wrote:
> >
> > > HI all,
> > > I have  2 sqlmaps that use LRU cache.
> > >
> > > Now sqlmap1 work fine.
> > > Cache is used for SELECT and invalidated on INSERT, UPDATE, DELETE
> > >
> > > The sqlmap2 should be cached too but since uses an inner join with
> > > table in sql map1 too should be invaldated when sqlmap1 is INSERT,
> > > UPDATE, DELETE
> > >
> > > So how I can Invalidate a cache in one sqlmap from another sql map?
> > > Is there a way to refer to a differente map?
> > > Is there a way to actually define all caches in a separate config
> > > file?
> > >
> > > I'm using SVN code and Vstudio 2005
> > >
> > > Thanks
> > >
> > > Manu
> > >
> >
> >
>

Re: Multiple cache and invalidation

Posted by Emmanuele De Andreis <ma...@gmail.com>.
Thanks it works perfectly.
I have one more question on namespaces.

My sqlmap1 has namespace "Name", so I first assumed that any SELECT
will be combined to have it.
eg: a select like:
<select id="Select" ...
is inedeed recognized
<select id="Name.Select"
but this thorw an error on second Namemap, that complaints the select
id is already in use.
On the other side i have added the CacheModel namespace
cacheModel="CacheModels.NameCache" and this seems to be combined
automatically.

My cachemodel map is indeed:
<sqlMap
	namespace="CacheModels"
	xmlns="http://ibatis.apache.org/mapping"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
	<cacheModels>
		<cacheModel id="NameCache" implementation="LRU">

Why on cache namespace is added and on select is not added?
Thanks

Manu

On 9/25/05, Ron Grabowski <ro...@yahoo.com> wrote:
> To reference a cache model or a statement in another sqlMap file, turn
> on namespaces and use the full namespace of the item.
>
> The code in SVN allows a sqlMap to contain just a cacheModels node:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <sqlMap namespace="CacheModels"
> xmlns="http://ibatis.apache.org/mapping"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>  <cacheModels>
>  <cacheModel id="UserCache" implementation="MEMORY">
>   <property name="Type" value="Strong" />
>   <flushInterval hours="2" />
>   <flushOnExecute statement="User.Insert" />
>   <flushOnExecute statement="User.Update" />
>   <flushOnExecute statement="User.Delete" />
>  </cacheModel>
>  </cacheModels>
> </sqlMap>
>
> The code in SVN also delays associating cacheModels with statements
> until all statements have been processed so you can include your
> cacheModel sqlMap file before or after your other sqlMap files.
>
> --- Emmanuele De Andreis <ma...@gmail.com> wrote:
>
> > HI all,
> > I have  2 sqlmaps that use LRU cache.
> >
> > Now sqlmap1 work fine.
> > Cache is used for SELECT and invalidated on INSERT, UPDATE, DELETE
> >
> > The sqlmap2 should be cached too but since uses an inner join with
> > table in sql map1 too should be invaldated when sqlmap1 is INSERT,
> > UPDATE, DELETE
> >
> > So how I can Invalidate a cache in one sqlmap from another sql map?
> > Is there a way to refer to a differente map?
> > Is there a way to actually define all caches in a separate config
> > file?
> >
> > I'm using SVN code and Vstudio 2005
> >
> > Thanks
> >
> > Manu
> >
>
>

Re: Multiple cache and invalidation

Posted by Ron Grabowski <ro...@yahoo.com>.
To reference a cache model or a statement in another sqlMap file, turn
on namespaces and use the full namespace of the item.

The code in SVN allows a sqlMap to contain just a cacheModels node:

<?xml version="1.0" encoding="UTF-8" ?>
<sqlMap namespace="CacheModels"
xmlns="http://ibatis.apache.org/mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <cacheModels>
  <cacheModel id="UserCache" implementation="MEMORY">
   <property name="Type" value="Strong" />
   <flushInterval hours="2" />
   <flushOnExecute statement="User.Insert" />
   <flushOnExecute statement="User.Update" />
   <flushOnExecute statement="User.Delete" />
  </cacheModel>
 </cacheModels>
</sqlMap>

The code in SVN also delays associating cacheModels with statements
until all statements have been processed so you can include your
cacheModel sqlMap file before or after your other sqlMap files.

--- Emmanuele De Andreis <ma...@gmail.com> wrote:

> HI all,
> I have  2 sqlmaps that use LRU cache.
> 
> Now sqlmap1 work fine.
> Cache is used for SELECT and invalidated on INSERT, UPDATE, DELETE
> 
> The sqlmap2 should be cached too but since uses an inner join with
> table in sql map1 too should be invaldated when sqlmap1 is INSERT,
> UPDATE, DELETE
> 
> So how I can Invalidate a cache in one sqlmap from another sql map?
> Is there a way to refer to a differente map?
> Is there a way to actually define all caches in a separate config
> file?
> 
> I'm using SVN code and Vstudio 2005
> 
> Thanks
> 
> Manu
>