Closed ccocchi closed 12 years ago
Great! Just need a couple things.
Thanks!
I added the method to the benchmark and to the wrapper, here are the results :
Before
exist-missing: libm:ascii 0.230000 0.200000 0.430000 ( 0.875489)
exist-missing: libm:ascii:pipeline 0.240000 0.260000 0.500000 ( 0.984436)
exist-missing: libm:ascii:udp 0.190000 0.130000 0.320000 ( 0.843025)
exist-missing: libm:bin 0.260000 0.300000 0.560000 ( 1.040943)
exist-missing: libm:bin:buffer 0.250000 0.340000 0.590000 ( 1.066506)
exist: libm:ascii 0.200000 0.210000 0.410000 ( 0.847553)
exist: libm:ascii:pipeline 0.210000 0.250000 0.460000 ( 0.858453)
exist: libm:ascii:udp 0.160000 0.110000 0.270000 ( 0.644295)
exist: libm:bin 0.200000 0.270000 0.470000 ( 0.904462)
exist: libm:bin:buffer 0.210000 0.310000 0.520000 ( 0.958519)
After
exist-missing: libm:ascii 0.120000 0.180000 0.300000 ( 0.658207)
exist-missing: libm:ascii:pipeline 0.130000 0.270000 0.400000 ( 0.718886)
exist-missing: libm:ascii:udp 0.080000 0.110000 0.190000 ( 0.433517)
exist-missing: libm:bin 0.110000 0.190000 0.300000 ( 0.633672)
exist-missing: libm:bin:buffer 0.130000 0.260000 0.390000 ( 0.710204)
exist: libm:ascii 0.080000 0.180000 0.260000 ( 0.588192)
exist: libm:ascii:pipeline 0.130000 0.260000 0.390000 ( 0.668358)
exist: libm:ascii:udp 0.050000 0.100000 0.150000 ( 0.325765)
exist: libm:bin 0.080000 0.170000 0.250000 ( 0.574753)
exist: libm:bin:buffer 0.060000 0.130000 0.190000 ( 0.352050)
About the method name, I chose exist
over exist?
, because for me, when you suffix your method with an interrogation mark, you expect a boolean response. Memcached#exist
only expose memcached_exist
from the lib and therefore can raise a NotFound error.
Then in the wrapper (or other applications) you can handled this error as you want, returning trusly / falsy values here, and I think that's where the exist?
method belongs.
But this is only my point view, it can be changed ;)
Looks good to me and I agree with your reasoning about the name.
Add a comment documenting the new method in memcached.rb and I will merge and release.
Done
This PR add the function memcached_exist() to libmemcached. This is a port from the function introduced in version 0.53 of libmemcached.
The wrapper expose this method through the
exist
method, that returns nil in case the key exist or raises Memcached::NotFound is it doesn't.This is a performance gain for store using memcached gem as client and implementing the
exist?
method. For example, using this store, here are the results :