开发者

Tokyo Cabinet cluster and PHP (via memcache)

开发者 https://www.devze.com 2022-12-15 15:29 出处:网络
I have 2 serversrunning tokyo cabinet in a cluster (2 hard drives so 4 in开发者_StackOverflowstances of Tokyo Cabinet). if it\'s just one instance of tokyo cabinet it\'s fairly straight forward to use

I have 2 servers running tokyo cabinet in a cluster (2 hard drives so 4 in开发者_StackOverflowstances of Tokyo Cabinet). if it's just one instance of tokyo cabinet it's fairly straight forward to use php memcache protocol to communicate. My question is how do you connect php if it's cluster?

Option 1: $memcache->connect('memcache_host', 11211); Using this option you can only connect to on instance of tokyo cabinet.

Option 2: $memcache = new Memcache; $memcache->addServer('memcache_host', 11211); $memcache->addServer('memcache_host2', 11211); Using this, you can connect to multiple, but are the data stored correctly in the cluster?

Thank you!


Use option 2 and let the client library do its thing. You can rest assured that you data will be distributed to all the memcached instances in the pool.

You could take a look at PHP Memcached library (notice the D at the end), it has some nice features you can take advantage of (it has a different algorithm for distributing data which you might find useful).

0

精彩评论

暂无评论...
验证码 换一张
取 消