UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '2wXQJX3JoVpuDg+VcvVar87KXvb8s7k69JZGy19Pns8='
WHERE
key_id = '168c5ed585ca0c9090bcdf61af3a47075b56599f575a458a6f8bf70c68981df2'
AND (
token = '2wXQJX3JoVpuDg+VcvVar87KXvb8s7k69JZGy19Pns8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)