In his his book "Gauge Fields and Strings" Polyakov introduces the compact QED on a cubic lattice in 3D Euclidean space as: $$ S\left[ \left\{ A_{\mathbf{r},\mathbf{\alpha}}\right\} \right]=\frac{1}{2g^2}\sum_{\mathbf{r},\mathbf{\alpha},\mathbf{\beta}}(1-\cos{F_{\mathbf{r},\mathbf{\alpha}\mathbf{\beta}}}) $$
Where $F$ is the net flux through the plaquette which is spanned by the lattice vectors $\mathbf{\alpha}$ and $\beta$ at point $\mathbf{r}$ and is given by: $$ F_{\mathbf{r},\mathbf{\alpha}\mathbf{\beta}}=A_{r,\alpha}+A_{r+\alpha,\beta}-A_{r,\beta}-A_{r+\beta,\alpha}$$ Which intuitively is the curl of $A$ around the plaquette. The gauge transformation is defined as: $$ A_{r,\alpha}\to A_{r,\alpha}-\phi_{r}+\phi_{r+\alpha} $$ Under which the action is invariant. One obvious result is that the total flux through any closed Gaussian surface is zero. This is true because: $$\sum_{p\in cube} F_p=0$$ As each gauge field on each link appears twice with different signs in the above sum. So it is impossible to have monopoles in this system except for Dirac monopoles which can be built by assuming that the flux through 5 faces of a cube has the same sign while one face has a net flux with negative sign such that the total flux remains zero.
But then, he (Polyakov) states that this flux (which only goes through one of the faces of a cube) is quantized. I do not know how to prove this. It seems that a singular gauge transformation is necessary (according to a paper by 't Hooft) and we need to couple the gauge field to another (probably matter) field, but I cannot find a way to implement that transformation in the lattice model and even one might ask why should we couple $A$ to another degree of freedom. This point is also mentioned here: https://physics.stackexchange.com/a/202806/90744 again without any proof.
The book uses another action which is claimed to be equivalent to the original action, which is given by: $$ S=\frac{1}{4g^2}\sum_{r,\alpha,\beta}(F_{r,\alpha \beta}- 2\pi n_{r,\alpha \beta})^2 $$ Where $n$ is an integer valued field. This action in general is not equivalent to the original action. because here we are allowing deviations from non-periodicity of $A$ to contribute and therefore we can only use it in the small $g$ limit.