diff --git a/src/lib/op_set.cc b/src/lib/op_set.cc index 28e5b749..ac52e993 100644 --- a/src/lib/op_set.cc +++ b/src/lib/op_set.cc @@ -78,6 +78,9 @@ int op_set::_parse_text_server_parameters() { int op_set::_parse_binary_request(const binary_request_header& header, const char* body) { if (header.get_extras_length() == _binary_request_required_extras_length && this->_entry.parse(header, body) == 0) { + if (this->_entry.version > 0) { + this->_behavior |= storage::behavior_cas; + } this->_entry.flag = ntohl(*(reinterpret_cast(body))); this->_entry.expire = util::realtime(ntohl(*(reinterpret_cast(body + 4)))); shared_byte data(new uint8_t[this->_entry.size]); @@ -129,7 +132,7 @@ int op_set::_run_server() { } if (r_storage == storage::result_stored || r_storage == storage::result_touched) { - if (this->get_ident() == "cas"){ + if ((this->_behavior & storage::behavior_cas) || this->get_ident() == "cas"){ stats_object->increment_cas_hits(); } else if (this->get_ident() == "touch"){ stats_object->increment_touch_hits(); @@ -138,7 +141,7 @@ int op_set::_run_server() { this->_is_sync(this->_entry.option, this->_cluster->get_replication_type())); } else { - if (this->get_ident() == "cas"){ + if ((this->_behavior & storage::behavior_cas) || this->get_ident() == "cas"){ if (r_storage == storage::result_exists){ stats_object->increment_cas_badval(); } else if (r_storage == storage::result_not_found) { diff --git a/test/lib/test_op_set.cc b/test/lib/test_op_set.cc index ec44b5ce..ff4135cf 100644 --- a/test/lib/test_op_set.cc +++ b/test/lib/test_op_set.cc @@ -87,6 +87,7 @@ namespace test_op_set cut_assert_equal_int(1, op._entry.flag); cut_assert_equal_double(stats_object->get_timestamp() + 60, 2, op._entry.expire); cut_assert_equal_int(5, op._entry.size); + cut_assert_equal_int(5, op._entry.version); cut_assert_equal_memory("value", 5, op._entry.data.get(), 5); char* dummy; cut_assert_equal_int(-1, c->readsize(1, &dummy));