4

enter image description here

The following step has followed:

telnet localhost 11211
set Test 0 100 10
get Test 
CLIENT_ERROR bad data chunk
ERROR
set amit 2 2 2 
get amit 
CLIENT_ERROR bad data chunk
ERROR
TIGER
  • 2,864
  • 5
  • 35
  • 45
Amit Bajaj
  • 41
  • 1
  • 3

4 Answers4

6

In my case I was providing the value but the bytes were not exactly what I was mentioning in the set command, for the format of the command is:

set KEY META_DATA EXPIRY_TIME LENGTH_IN_BYTES

so for those who were just copy pasting the command without knowing as to why is it not storing the key and came here for the answer, this might help:

You need to provide the value of exactly the same bytes which you have mentioned in the last parameter of the set command

the following won't work:

enter image description here

also the following won't:

enter image description here

So when you enter the value it has to be exactly the same bytes, like this:

enter image description here

shabby
  • 3,002
  • 3
  • 39
  • 59
3

Although you do not ask a specific question, i presume you want to store a value. You could test with the default example from the Memcached manual.

You define that you want to store a key, but don't specify a value.

The following example specifies that you want to save a key "tutorialspoint", no flags, timeout of 900 and reserve 9 bytes for a value. Those 9 bytes are specified in the next line: "memcached". In your example i don't see a value.

set tutorialspoint 0 900 9
memcached
STORED

get tutorialspoint
VALUE tutorialspoint 0 9
memcached

END
phulstaert
  • 71
  • 2
  • How to remove the error "CLIENT_ERROR bad data chunk". – Amit Bajaj Apr 28 '17 at 11:51
  • As i said. With the "set Test 0 100 10" you specify that the next 10 characters will contain the value, but you do not give a value. Hence you do not get the confirmation 'STORED'. Although you did not set the value, you still try to retrieve something. – phulstaert May 17 '17 at 07:54
2

‘set Test 0 100 10’, then enter a value which the length is equal to 10。

1

the set command takes 4 arguments:

  1. key - this is an arbitrary key you'll later use to retrieve the value
  2. flag - use 0 for no flags
  3. ttl - time to live in seconds. this is how long memcache will hold your value.
  4. size - in bytes. Byte count of your value.

In my case I was neglecting to calculate the number of bytes and that was why I kept getting the "client error bad data chunk" error

dlibian
  • 26
  • 2