It would be good to have a comment at the top of the file explaining what keys get set in couchbase and to what values, would make it easier to follow what's going on here.