views:

254

answers:

2
+2  Q: 

Memcache sharing

Is it possible to share a single instance of a Memcache between multiple projects.

Suppose I push one object inside the memcache in one project, is it possible for me to retrieve the same object from a different project. ?

+6  A: 

Memcache is just a memory store. It can run across multiple machines. Theres no reason that two entirely different processes can't talk to each other via it.

Let me clarify. You can run memcache no one or more servers. You can configure your clients to speak to a specific set of instances. You can run two (or more) different memcache processes on the same host (listening to different IP addresses and/or ports) and they're completely independent.

If your two applications talk to the same instance(s) then there's no reason they can't communicate.

The complication comes if you talk to multiple instances and partition your data (ie split it across different instances) then your clients need to know which instance to get the data from or put the data into. If you're using the same client library (eg both your clients are PHP5) then that's not a drama. If they aren't the same then you have to handle that problem somehow.

The other issue if you use different technologies is you have to think about the interchange format since the custom serialization in PHP won't be so readable in Java or C#. Typical choices are XML or even JSON.

cletus
I completely misread the question, thanks for pointing that out :)
Binary Worrier
+2  A: 

Yes, as long as each project configures the memcache nodes in same the way, and generates a key for a cache element in the same way, they can share data.

Paul Dixon