UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'iOroQNU6JrJK5ENfBm5qdDg1zzmizhYmYlUx6pn2cl4='
WHERE
key_id = '5318a24c2c0bd85c83dce2739d882a8f8519f6738f884771adcb50432f44d3a9'
AND (
token = 'iOroQNU6JrJK5ENfBm5qdDg1zzmizhYmYlUx6pn2cl4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)