UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'tAIcFRz42qoQXAL3rFg7SFfi7fwcvIpwWyVDbE13RfI='
WHERE
key_id = 'af1716337d3eedf2e6b0866fceac13b52f052b63899e6ca466e8990722a63bac'
AND (
token = 'tAIcFRz42qoQXAL3rFg7SFfi7fwcvIpwWyVDbE13RfI='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)