use setnx for race condition prevention