UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'OrZ4n9TdaoUiuHDl1j6BWqj78Ml7Khhq2st1fTalGU0='
WHERE
key_id = '31f5376ae7639ac689dea0c31cbf0b30ed523bdc8cdbb863446708ecad22b004'
AND (
token = 'OrZ4n9TdaoUiuHDl1j6BWqj78Ml7Khhq2st1fTalGU0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)