N1QL Memcache Upsert



I want to insert a key, value to a memcache bucket called “MyMem” with an expiry of 7 days using N1QL.
The server version is 4.0.
how can I do it? please give me an example.



Also I have also some issues when doing upsert in memcached bucket

  • echo Upsert INTO MyMem (KEY, VALUE) VALUES (“1545-2015-07-17”,{“RecID”:“1545-2015-07-17”,“RecName”:“1”}) RETURNING * ;
  • /opt/couchbase/bin/cbq -engine=http://.:8093
    Couchbase query shell connected to http://.:8093/ . Type Ctrl-D to exit.
    “requestID”: “428e6605-1ec8-45de-b8f2-a1b274c93d34”,
    “errors”: [
    “code”: 12013,
    “msg”: “This bucket type is not supported memcached”
    “status”: “fatal”,
    “metrics”: {
    “elapsedTime”: “3.756522ms”,
    “executionTime”: “3.633448ms”,
    “resultCount”: 0,
    “resultSize”: 0,
    “errorCount”: 1


looks like N1QL doesnt support memcached!


No way to insert into this memcached bucket :frowning: I have tried N1QL and cbdocloader and none it is working!

/opt/couchbase/bin/cbdocloader -n ...*:8091 -u Administrator -p pwd123 -b MyMem /home/user/2015-07-17.zip
[2015-07-17 08:40:14,780] - [rest_client] [140573738026816] - INFO - existing buckets : [u’default’, u’mdb’, u’MyMem’, u’test_mdb’]
[2015-07-17 08:40:14,781] - [rest_client] [140573738026816] - INFO - found bucket MyMem
bucket creation is successful
2015-07-17 08:40:14,845: mt skipping bucket that is not a couchbase-bucket: MyMem
[2015-07-17 08:41:15,116] - [rest_client] [140573738026816] - INFO - vbucket map is not ready for bucket MyMem after waiting 60 seconds
2015-07-17 08:41:15,116: mt vbucket map is not ready for bucket MyMem after waiting 60 seconds
Traceback (most recent call last):
File “/opt/couchbase/lib/python/cbdocloader”, line 330, in
File “/opt/couchbase/lib/python/cbdocloader”, line 318, in main
File “/opt/couchbase/lib/python/cbdocloader”, line 260, in populate_docs
self.bucket = cb[self.options.bucket]
File “/opt/couchbase/lib/python/couchbase/client.py”, line 161, in getitem
return self.bucket(key)
File “/opt/couchbase/lib/python/couchbase/client.py”, line 118, in bucket
return Bucket(bucket_name, self)
File “/opt/couchbase/lib/python/couchbase/client.py”, line 217, in init
File “/opt/couchbase/lib/python/couchbase/couchbaseclient.py”, line 685, in init
File “/opt/couchbase/lib/python/couchbase/couchbaseclient.py”, line 821, in reconfig_vbucket_map
Exception: vbucket map is not ready for bucket MyMem


You will want to use a Couchbase bucket type. memcached buckets are are intentionally very simple for a pure LRU caching use case. Couchbase buckets have facilities like DCP which is necessary infrastructure for things like query.


I want to insert key values into memcached. There is no way to do it?
I want to use memcached because I don’t want to store in disk my data, want them available in memory and for a few hours.


@ingenthr ok I will use couchdb instead of membase … how to set expiration in json document so after loading using cbdocloader ,ddouments will expire and deleted after 1 day?


I don’t believe cbdocloader supports setting an expiration. It may be simpler to write a script in whatever language you’re comfortable with as it seems like you may need some specific behavior.