N1QL Memcache Upsert


#1

hello,

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.
thanks


#2

@geraldss

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
    }
    }

#3

looks like N1QL doesnt support memcached!


#4

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
pump_transfer.exit_handler(DocLoader().main(sys.argv))
File “/opt/couchbase/lib/python/cbdocloader”, line 318, in main
self.populate_docs()
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
self.bucket_password)
File “/opt/couchbase/lib/python/couchbase/couchbaseclient.py”, line 685, in init
self.reconfig_vbucket_map()
File “/opt/couchbase/lib/python/couchbase/couchbaseclient.py”, line 821, in reconfig_vbucket_map
(self.bucket))
Exception: vbucket map is not ready for bucket MyMem


#5

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.


#6

@ingenthr
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.


#7

@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?


#8

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.