We have 2 applications servers (coldfusion / Java) and one memcached. I want to setup my memcached server/client like that. When server 1 add value for key it should be available also for server 2. And in opposite way also.
Now when i add value for key on server 1 it is not readable or editable on second server. How to set it up
I use spymemcached as a client library.
Thanks for your help
Everything was set in a right way, but setting a complex value (Structure or Array) made those key/value pair unavailable for other server. Now i serialize all my values to JSON and it works fine. Maybe in Memcached version 1.4.5 it is changed, but for version 1.2.6 serializing values is the good way of fixing it.
<!--- Setting up Memcached Client --->
<!--- Add code in OnApplicationStart in Application.cfc --->
<cfset AU = createObject("java", "net.spy.memcached.AddrUtil").init() />
<cfset Application.MemCacheD = createObject("java", "net.spy.memcached.MemcachedClient").init(AU.getAddresses("127.0.0.1:11211")) />
<!--- Adding values: --->
<cfset memCacheName = "myKey" />
<cfset myValue = StructNew() />
<cfset myValue['var1'] = 'var1 value' />
<cfset Application.MemCacheD.add(memCacheName, 3600, serializeJSON(myValue)) />
<!--- Getting values: --->
<cfset memCacheName = "myKey" />
<cfset MemCachedRet = Application.MemCacheD.get(memCacheName) />
<cfif isDefined('MemCachedRet')>
<!--- value is available from mamcached --->
<cfelse>
<!--- get value from db and save to memcached --->
</cfif>