Add setBucket function #19

Merged
merged 3 commits into from Nov 18, 2013

Projects

None yet

2 participants

@bpospichil

Hi,

I added the support to libmemcached vbuckets function, making the match to memcached_bucket_set function:

LIBMEMCACHED_API
memcached_return_t memcached_bucket_set(memcached_st *self,
const uint32_t *host_map,
const uint32_t *forward_map,
const uint32_t buckets,
const uint32_t replicas);

'host_map' needs to have 'buckets' elements;
'forward_map' needs to have 'buckets' elements or NULL;

I made tests writing keys using libmemcached and reading using php-memcached and vice-versa.

@mkoppanen mkoppanen commented on the diff Oct 17, 2013
php_memcached.c
+ }
+ } else {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "array size mismatch");
+ ok = 0;
+ break;
+ }
+ }
+
+ if (i != buckets) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "array size mismatch");
+ ok = 0;
+ }
+
+ i = 0;
+ if (ok != 0 && forward_map != NULL) {
+ fm = (uint32_t*)malloc(buckets * sizeof(uint32_t));
@mkoppanen
mkoppanen Oct 17, 2013 Member

This should probably be emalloc and efree later. same with hm.

@mkoppanen
Member

DISTRIBUTION_VIRTUAL_BUCKET constants seems to be missing. Can you add that and a test case and i'll merge.

@mkoppanen mkoppanen was assigned Oct 18, 2013
@mkoppanen mkoppanen merged commit f083d9d into php-memcached-dev:master Nov 18, 2013
@bpospichil

Hi Mikko, weirdly I did not received any message about your comment in my pull request. I just saw it because I received an e-mail notifying the merge. Sorry for not keeping on touch and thanks for the follow up of my fork.

@mkoppanen
Member

No worries! The most important thing is that it's in now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment