UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '7YPtmmGPrS+Nx/1hld1akO5ytcsp6pzArXdA+8+kxYw='
WHERE
key_id = '49b12d91000e33daad422954f09dde3b2217a077a148b1a9338c3bc92245eed3'
AND (
token = '7YPtmmGPrS+Nx/1hld1akO5ytcsp6pzArXdA+8+kxYw='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)