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