Yes !!! it works .... ! it is not necessary to modify the iBatis
source code, in order to implement a new Cache Controller !.

In my case, it works only if I create a typeAlias :

<alias>
<typeAlias alias="MEM"
             type="MemcachedCacheController.MemcachedController,
MemcachedCacheController"/>
</alias>

<cacheModels>
   <cacheModel id="MyCache" implementation="MEM" >
     <flushInterval hours="24"/>
     <flushOnExecute statement="insert"/>

     <property name ="minutes_standard_expire" value="1"/>
     <property name ="ServerList" value=" .... "/>
   </cacheModel>

Thanks Ron,
now I can improve my cache provider, without modifing ibatis source code.

Giancarlo

PS. for newbies : in sqlmap.confg you have to set validateSqlMap to
false, in order to disable the xml validation with xsd file.
<setting validateSqlMap = "false"/>


On 10/27/06, Ron Grabowski <[EMAIL PROTECTED]> wrote:
This should work...

<cacheModel id="account-cache" implementation="Company.IBatisNet.MemCachedCacheModel, 
Company.IBatisNet" >
 <flushInterval hours="24"/>
 <flushOnExecute statement="UpdateAccountViaInlineParameters"/>
 <flushOnExecute statement="UpdateAccountViaParameterMap"/>
 <property name="serverList" value="127.0.0.1,192.168.1.1"/>
</cacheModel>

----- Original Message ----

From: Tite Etoundi <[EMAIL PROTECTED]>

To: [email protected]

Sent: Wednesday, October 25, 2006 8:56:04 AM

Subject: RE : Re: distributed cahing/iBATIS.Net



Hi all,



  about caching in iBATIS, I've downloaded memcacheddonet library and I've find 
how someone can write an ICacheController as Ron's last post hereafter. But, my 
question is how can I, after writing MemcachedCacheController as Ron did, make 
iBATIS uses this controller instead of the default ones: LRU, MEMORY and FIFO. 
I've seen SqlMap.xsd it recognizes only LRU, MEMORY and FIFO. But, as I saw in 
that file, I could insert another cache implementation like MC for 
MemcachedCacheController . The problem is that somewhere it is asked to provide 
the implementation type as type alias, so where can someone tell iBATIS to use 
MemcachedCacheController ?



  Thanks,



  Tite



Ron Grabowski <[EMAIL PROTECTED]> a écrit :

  The ICacheController  interface only has a few members to it. I didn't see 
anything in the MemcachedClient about removing multiple keys.



I haven't tested the code below but I'm able to run the MemcachedBench program 
against a win32 build of memcached:



http://jehiah.com/projects/memcached-win32/



I think the ICacheController should have a Shutdown member so 3rd party caches 
can clean up when the application shutsdown.



Of course all the properties on the pool object should be settable by

the properties argument. The properties argument should also have a key

to prefix items put into the cache so IBatisNet plays nice with other

programs using the cache. It should be possible to also integrate the 
FlushInterval construct into this implementation.



// untested - inspired by Memcached.MemcachedBench.MemcachedBench

public class MemcachedCacheController : ICacheController

{

private SockIOPool pool;

private MemcachedClient  memcachedClient;



public object this[object key]

{

get { return memcachedClient.Get(Convert.ToString(key)); }

set { memcachedClient.Set(Convert.ToString(key), value); }

}



public object Remove(object key)

{

return memcachedClient.Delete(Convert.ToString(key));

}



public void Flush()

{

// empty

}



public void Configure(IDictionary properties)

{

string servers = Convert.ToString(properties["server"]);



pool = SockIOPool.GetInstance();

pool.SetServers(servers.Split(','));

pool.InitConnections = 3;

pool.MinConnections = 3;

pool.MaxConnections = 5;

pool.SocketConnectTimeout = 1000;

pool.SocketTimeout = 3000;

pool.MaintenanceSleep = 30;

pool.Failover = true;

pool.Nagle = false;

pool.Initialize();



memcachedClient = new MemcachedClient();

memcachedClient.EnableCompression = false;

}

}



----- Original Message ----

From: Alexandre Grenier

To: [email protected]

Sent: Friday, October 6, 2006 2:51:41 PM

Subject: RE: distributed cahing/iBATIS.Net





I've done some fooling around with memcached... I still haven't looked into how 
to write a custom cache provider for ibatis though. If no one's done it by the 
time I get there, then I'll probably do it :)



Alex





-----Original Message-----

From: Ron Grabowski [mailto:[EMAIL PROTECTED]

Sent: Thursday, October 05, 2006 7:22 PM

To: [email protected]

Subject: Re: distributed cahing/iBATIS.Net





Someone needs to write an IBatisNet cache client for memcached:



http://www.danga.com/memcached/



There is a closed source solution called NCache but its probably $$$.





----- Original Message ----



From: Tite Etoundi



To: [email protected]



Sent: Tuesday, October 3, 2006 7:27:27 PM



Subject:  distributed cahing/iBATIS.Net







Hi evry body,







I am new in using iBATIS as a data mapper in the project. But it works well. It 
allow me to have a better architecture of my application so it isolates 
correctly the data access. But my concern about it is distributed caching. Does 
iBATIS allows this kind of stuff or is there an open source solution that can 
be used with iBATIS like OSCache for iBATIS java?







Thank



Découvrez un nouveau moyen de poser toutes vos questions quel que soit le sujet 
! Yahoo! Questions/Réponses pour partager vos connaissances, vos opinions et 
vos expériences. Cliquez ici.

























  Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !  
Profitez des connaissances, des opinions et des expériences des internautes sur 
Yahoo! Questions/Réponses.








Reply via email to