-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The file system cache is not removing files properly #61
Comments
Not the owner or a maintainer, but may I ask a few questions?
What features is the in-memory cache? Like, what are you trying to do? Or what do you want it to do?
Do you mean you manually clean up the FS cache?
What do you mean by this? TTL of 1 day is not good enough for your use case, or are expired cache files not removed? |
Some background: I maintain an app called LolByte which relies on a web server that uses this library to talk to the Riot API.
Cache data in-memory rather than on the file system. Even if the cache grew unbounded it’s easier to restart the JVM / container than manually clean up files. If the issue with the FS growing were fixed I wouldn’t need the in-memory implementation at all.
Yes eventually the FS cache takes up all the disk space on my server. I try to clean it up when the disk utilization hits 80% but I’d like to remove this toil.
TTL of 1 day is fine. I suspect the TTL may be getting enforced correctly but for whatever reason files are still being left on the FS. I haven’t looked deep into the code to verify this but like I said my disk utilization slowly climbs up over time. |
R4j supports in-memory caching, but I assume you want to cache everything and not only Match data.
That's what I was curious about. I haven't tested this project yet, but I have read its source code, esp the caching part.
I can only think of 3+1 things:
One last question (might help us fix this issue): What OS/FS/JRE are you using? |
I don't know how I missed this, but the However, AFAIK, that does not directly affect how it works.
* It will eventually get updated. Apparently, // Run using `jshell -R -ea -- Test.java` (enable assertions)
// Tested on Windows 10 x64, the default FS (NTFS), and OpenJDK 15.
import java.nio.file.*;
import java.nio.file.attribute.FileTime;
import java.time.Instant;
var path = Paths.get("some.txt");
// Scenario 1: Reading attributes does not change last accessed time.
{
var accessed1 = ((FileTime)Files.getAttribute(path, "lastAccessTime")).toMillis();
Thread.sleep(2 * 1000); // in seconds * 1000
var accessed2 = ((FileTime)Files.getAttribute(path, "lastAccessTime")).toMillis();
assert accessed2 == accessed1;
}
// Scenario 2: Setting modified time updates last accessed time.
{
var accessed1 = ((FileTime)Files.getAttribute(path, "lastAccessTime")).toMillis();
Files.setLastModifiedTime(path, FileTime.from(Instant.now()));
Thread.sleep(2 * 1000); // in seconds * 1000
var accessed2 = ((FileTime)Files.getAttribute(path, "lastAccessTime")).toMillis();
// The following throws an assertion error if `sleep` is commented out.
assert accessed2 > accessed1;
}
/exit |
One last point: |
Thanks for all your help on this!
Ideally, yes!
Here is where I initialize R4J: https://github.com/lolbyte-code/lolbyte-service/blob/4c99f9ea13c88634d369403cd0e6ea8c4f582a29/src/main/kotlin/com/badger/lolbyte/client/R4JClient.kt#L42C19-L42C22. I don't think this is setting the TTL to INFINITY but correct me if I am wrong.
Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-76-generic x86_64) |
@ReprimandedKaito - Doesn't look like I have permissions to tag this as a bug? |
No its not, thats on purpose. The cache clearing timer isnt started with the default cache provider. Since it sets the TTL to "use-hints", it will be left on disk, and updated when the timer expires. Looks like it doesnt clear based on the cache-hints if thats not set tho, so Ill look into that later when i have a chance |
Would be great to have this option available. I've found that the file system cache slowly eats up disk space and I have to intermittently clear it out (TTL of 1 day doesn't seem to actually clean up the fs).
The text was updated successfully, but these errors were encountered: