How to refresh the cache file I wrote a judgment in a loop (when the length of array a is less than 1, it will be executed once) into the cache operation, and vice versa, do not write data into the cache. The result is an incorrect result or the value of array a. It does not change. just how to refresh the cached file?
How to refresh cached files
In a loop, I wrote a judgment statement (once the length of array a is less than 1) into the cache. On the contrary, I did not write it into the cache.
The problem arises here.
When the execution of array a is less than 1, the suffix is saved to B .txt. after that, I read this slow B .txt File (I opened B .txt with the help of the script to get the correct content), and the result is an incorrect response file.
What should I do? To solve this problem.
------ Solution --------------------
No code, no truth
------ Solution --------------------
Did I use fclose before reading it? In addition, I simplified the problem and extracted the code from the project. (The problem is also analyzed.) then I tested it.
------ Solution --------------------
I didn't say so. let's take a look at the cache class first. No one knows how to implement caching.
------ Solution --------------------
The problem does not occur in file read/write. check the entire logic.
Of course, you cannot pass the following test example.
PHP code
File_put_contents ('zzz', 'A'); $ s = file_get_contents ('zzz'); echo $ s; $ fp = fopen ('zzz', 'w '); fwrite ($ fp, 'B'); $ fp = fopen ('zzz', 'r'); echo fgets ($ fp );
------ Solution --------------------
Static method. $ this may be a problem.