ID:133404
 
In continuously-hosted games, proper resource management is vital; in games with many dynamically generated icons and such, the RSC file could grow massively large in short amounts of time.

The only safety from this, then, is the cache_lifespan var:

(per the DM Reference)
Default value:
30 (days)
Number of days items that are not in use will be saved in the resource cache (.rsc file). Files uploaded by players are stored in the world's .rsc file for future use. If the file is not used for the specified amount of time, it will be removed to save space.


This gives little information with regards to the var's usage and actual implementation. My first question, then, is if all non-essential resources are purged via the cache_lifespan, or if only the user-uploaded files are. Dynamically generated resources can be a pain to use if there's nothing to clean them up when they're gone!

It also doesn't specify whether or not the value accepts fractional values, such as 0.5 for a half-day value. Further, there is no implementation specification here; one must assume that resources would be instantly cleaned after a day of inactivity if the lifespan is 1, but does this happen? Are resources perhaps purged only on server startup and shutdown, or does it happen regularly? The answer to this question is important to games which must regularly generate resources while maining a constant online presence.
Kuraudo wrote:
In continuously-hosted games, proper resource management is vital; in games with many dynamically generated icons and such, the RSC file could grow massively large in short amounts of time.

The only safety from this, then, is the cache_lifespan var:

(per the DM Reference)
Default value:
30 (days)
Number of days items that are not in use will be saved in the resource cache (.rsc file). Files uploaded by players are stored in the world's .rsc file for future use. If the file is not used for the specified amount of time, it will be removed to save space.

Just FYI (because we've been finally looking over this now), cache_lifespan doesn't actually do anything at the moment. The reason is that with 4.0, the resource system was changed to store all dynamic (uploaded) resources into a separate cache file that gets deleted at world end. This way you can be ensured that the world.rsc you compile never changes.

This means that, essentially, since 4.0 the cache_lifespan=0 has been in effect, and uploaded resources only persist until the world ends or reboots. Note that this doesn't really make a difference because in order to reference an uploaded resource in a different session, you most likely have it in a savefile, and that'll store the resource data too. The only exception we could think of was for those icon-uploading games where the user might upload the same resource multiple times in separate sessions-- so having that cached would save bandwidth.

Anyway, we're thinking of having cache_lifespan just apply to this dynamic cache. If we do that, setting it to 0 will give the current behavior.

As far as your original questions, only dynamic resources are purged, and that is done at world startup/reboot. We could look into garbage-collecting them in the case where the lifespan is shorter than the time that the world has been running, but I suspect that could be tricky (since we'd have to ensure that dynamic resources aren't referenced, even though they are expired).