diff options
author | dormando <dormando@rydia.net> | 2023-03-08 17:30:53 -0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2023-03-11 18:19:23 -0800 |
commit | c04701654413719d4abd7645c6d7b3fba4255e85 (patch) | |
tree | d415716c5ce3f9290c473bd5e82df4884bd5ab1d /memcached.c | |
parent | aef5b580a5b1528cd418433857adfd7a87f1b4e4 (diff) | |
download | memcached-c04701654413719d4abd7645c6d7b3fba4255e85.tar.gz |
meta: N flag changes append/prepend. ms s flag.
Sending 's' flag to metaset now returns the size of the item stored.
Useful if you want to know how large an append/prepended item now is.
If the 'N' flag is supplied while in append/prepend mode, allows
autovivifying (with exptime supplied from N) for append/prepend style
keys that don't need headers created first.
Diffstat (limited to 'memcached.c')
-rw-r--r-- | memcached.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/memcached.c b/memcached.c index 15bbf36..8e8a180 100644 --- a/memcached.c +++ b/memcached.c @@ -1532,7 +1532,7 @@ static int _store_item_copy_chunks(item *d_it, item *s_it, const int len) { } static int _store_item_copy_data(int comm, item *old_it, item *new_it, item *add_it) { - if (comm == NREAD_APPEND) { + if (comm == NREAD_APPEND || comm == NREAD_APPENDVIV) { if (new_it->it_flags & ITEM_CHUNKED) { if (_store_item_copy_chunks(new_it, old_it, old_it->nbytes - 2) == -1 || _store_item_copy_chunks(new_it, add_it, add_it->nbytes) == -1) { @@ -1563,7 +1563,7 @@ static int _store_item_copy_data(int comm, item *old_it, item *new_it, item *add * * Returns the state of storage. */ -enum store_item_type do_store_item(item *it, int comm, LIBEVENT_THREAD *t, const uint32_t hv, uint64_t *cas, bool cas_stale) { +enum store_item_type do_store_item(item *it, int comm, LIBEVENT_THREAD *t, const uint32_t hv, int *nbytes, uint64_t *cas, bool cas_stale) { char *key = ITEM_key(it); item *old_it = do_item_get(key, it->nkey, hv, t, DONT_UPDATE); enum store_item_type stored = NOT_STORED; @@ -1636,6 +1636,8 @@ enum store_item_type do_store_item(item *it, int comm, LIBEVENT_THREAD *t, const break; case NREAD_APPEND: case NREAD_PREPEND: + case NREAD_APPENDVIV: + case NREAD_PREPENDVIV: if (cas_res != CAS_NONE && cas_res != CAS_MATCH) { stored = EXISTS; break; @@ -1663,6 +1665,10 @@ enum store_item_type do_store_item(item *it, int comm, LIBEVENT_THREAD *t, const // it's original ref is managed outside of this function it = new_it; do_store = true; + // Upstream final object size for meta + if (nbytes != NULL) { + *nbytes = it->nbytes; + } } break; case NREAD_REPLACE: @@ -1692,6 +1698,8 @@ enum store_item_type do_store_item(item *it, int comm, LIBEVENT_THREAD *t, const switch (comm) { case NREAD_ADD: case NREAD_SET: + case NREAD_APPENDVIV: + case NREAD_PREPENDVIV: do_store = true; break; case NREAD_CAS: |