UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'HD7S6aTQbx1jXxpJ29P9arLFrVAaL5NRobU2s6k4a+A='
WHERE
key_id = 'c9f6989846b65db9c551fc690606e4011f98d6531fd74eb628e25e7fe2be4072'
AND (
token = 'HD7S6aTQbx1jXxpJ29P9arLFrVAaL5NRobU2s6k4a+A='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)