implement "Vary by" option

Change-Id: I13f402f16b9eedc9634a59cbed2953efb62e1a3f
Reviewed-on: http://review.couchbase.org/32270
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Pavel Paulau <pavel.paulau@gmail.com>