UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'dT5mVOYauz15tok2DWRApDBer+7xrS5E64mNy+6asms='
WHERE
key_id = '772a5729d9f69dee8b0d886777aa5c05a959ae6cd9a60e0011be4b4ea645079b'
AND (
token = 'dT5mVOYauz15tok2DWRApDBer+7xrS5E64mNy+6asms='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)