UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'X4MdCEHqAX4g/WUEOSlRxhztqzvBp1ESw7JbTyoDP6k='
WHERE
key_id = 'd50db0c219be0c5107707c2c03909714095ba12343c513eec86d4f788c4fc2f3'
AND (
token = 'X4MdCEHqAX4g/WUEOSlRxhztqzvBp1ESw7JbTyoDP6k='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)