Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error not set on get? #90

Open
cappelaere opened this issue Oct 2, 2016 · 1 comment
Open

error not set on get? #90

cappelaere opened this issue Oct 2, 2016 · 1 comment

Comments

@cappelaere
Copy link

cappelaere commented Oct 2, 2016

in node console
$ var memjs = require('memjs')
$ var client = memjs.Client.create()
$ client.get('hello', function(err, val) { console.log("err:"+err+" - val:"+val); })

$ err:null - world
$ client.get('nohello', function(err, val) { console.log("err:"+err+"- val:"+val); })
$ err:null - null

Assuming that 'hello' was set to 'world'
First call works as advertized
Second call should fail. It returns no data and err is not set.
??

Would be nicer to return "key not found" error.
There is a big difference with a key not found and a key set to null.

Thanks,
Pat

@alevy
Copy link
Member

alevy commented Oct 3, 2016

hrm... there is no way to get a null for an existing key, only an empty string. In the memcache protocol, it is possible to set a key to the empty string (""), but not to null.

Some libraries, like Dalli for Ruby, actually serialize all values, so Ruby's nil get's serialized to the bytestring "\x04\b0". So the actual value from the perspective of memcache is non-null. MemJs is, by design, as close to the protocol as possible---you can put whatever layer on top you want.

None-the-less, I'm not sure there's any harm in also setting the err to "key not found", so I'm happy to take a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants