UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '+4119r2vSUplOTig8hM/apUYO5l0qPNbkL8eLeUyxI4='
WHERE
key_id = '166a551127f106750842e00ca4f78e7b4da5186a1edcc6e9c964e7746d8d94ab'
AND (
token = '+4119r2vSUplOTig8hM/apUYO5l0qPNbkL8eLeUyxI4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)