Php: Groups of keys
Memcached supports a key/value pair system.
Is there a way to group keys together? And return all the keys within a group.
I don't need the items in the group to lock. I just need to get a list of keys.
I can keep a list of keys in a key/value pair. But in that case I might drop a key during a write.
It would be better to have this kind of logic built-in.
Alternatively, I could always use a prefix on key names. Is there a search feature to return keys matching a prefix?
Thanks
The Membase console supports creating buckets under the Manage->Data Buckets section.
I created two Memcached SASL buckets. How does the php Memcache::get and Memcache::set methods specify the bucket name?
Memcache get and set don't specify the bucket. Do you have a special client that specifies the bucket name?
http://www.php.net/manual/en/memcache.get.php
I've put the buckets on their own ports so I can use a separate connection to access each bucket.
Seems like I'm wasting connections.
I have a bucket ONLINE_USERS, how do I query all the keys in that bucket?
I obviously want to use the memcached client which can at least retrieve values from a list of keys rather than a separate call for each one:
http://www.php.net/manual/en/memcached.getmulti.php
Querying for all the keys in a bucket is not a scalable operation and would introduce locking. So an alternative would be to paginate the list of database users and query if each user key is online in a paginated way.
This would be slower but performance shouldn't be an issue in offline analysis.
Still it would be nice to dump the key/values to disk for faster analysis.
Looks like you've answered a lot of your own questions, I'll just fill in the last bit.
With the current software, you can use the TAP interface (http://www.couchbase.org/wiki/display/membase/TAP+Protocol) to get a stream of keys and values from a Membase server in a non-performance-impacting way.
I would also suggest taking a look at this post on maintaining a set/index within Membase: http://dustin.github.com/2011/02/17/memcached-set.html
Lastly, our 2.0 product will provide an even easier way to retrieve a list of keys by allowing you to map-reduce and index.
Perry
Is there a Windows php extension for the TAP protocol?
Not yet unfortunately.
I see there's a concept of buckets, but I really didn't expect needing a whole new port to group key/value pairs.
http://www.couchbase.org/wiki/display/membase/Data+partitioning+with+buc...
Is there a way to create buckets from php? Or anytime you need a bucket do you need to use the web admin panel? Or is the panel not capable of creating a bucket?