Fix the issue of seeing "Error while writing to artifact cache: an integer is required" during [cache check]

Apparently the order of args was swapped by mistake. Fixed the issue by using named param calling style and updated the arg validation which would fail tests if similar problem occurs.

Testing Done:
https://travis-ci.org/jinfeng/jinfeng-pants-fork/builds/39441973 has passed.

local tests:

PANTS_DEV=1 ./pants goal test ./tests/python/pants_test/cache/

Reviewed at https://rbcommons.com/s/twitter/r/1249/
Sync of https://github.com/pantsbuild/pants/commit/c60db2d310c6095fce427d219bdd7cda1aee4428