I just follow this post to test Couchbase View.When edit view use Couchbase GUI and save,the view didn't update immediately.
For example.With php scripts store some array to Couchbase.And define a named 'last' view in 'dev_sessions' document:
function (doc) {
if(doc.namespace == 'sessions') {
emit(doc.lastSeen, 1);
}
}
Then use curl to get the json result. First time:
$ curl
http://192.168.228.134:8092/default/_design/dev_sessions/_view/last/?group_level=1&reduce=true'
{"rows":[ ] }
Second:
$ curl 'http://192.168.228.134:8092/default/_design/dev_sessions/_view/last/?group_level=1&reduce=true'
{"rows":[
{"key":1352872218,"value":1},
{"key":1352879418,"value":3}
]
}
Another test,add a new array in php scripts:
'eb255262434407766f212d1b6f23' => array(
'namespace' => 'sessions',
"type" => "user",
"userID" => "1107",
'lastSeen' => time(),
'firstSeen' => time(),
"remoteAddress" => "2.3.4.5",
"location" => "Vienna/Austria",
"name" => "Golden K"
Run curl again,first time:
$ curl 'http://192.168.228.134:8092/default/_design/dev_sessions/_view/last/?group_level=1&reduce=true'
{"rows":[
{"key":1352872218,"value":1},
{"key":1352879418,"value":3}
]
}
Second time:
$ curl 'http://192.168.228.134:8092/default/_design/dev_sessions/_view/last/?group_level=1&reduce=true'
{"rows":[
{"key":1352875163,"value":1},
{"key":1352882363,"value":4}
]
}
If changed data or view script,click Views - 'Show Results'
button in Couchbase GUI,the first & second time does different.
Why View not update immediately?