Stop Cache from Filling Up?


Recommended Posts

I occasionally fill up my cache.  Because appdata and docker image are there, it means it takes down all my dockers.  Not a huge deal, since you just have to stop and start the docker service, but it's an inconvenience.

 

Is there a way for the system to not fill the cache drive up completely?  Say, leave it at 5% capacity to leave some breathing room for dockers?

 

I've got a 250GB drive, 70GB of which is in use with appdata and docker image.  The rest fills up surprisingly quickly.  Especially when a docker triggers some large downloads that are unpacked and copied to the array whilst you're asleep...

 

There may be a way to do this, and I know that the mover scripts in the user scripts plugin is one option, but throwing this out there.  Of course, a larger cache drive (or second unassigned drive) would help...

Link to comment

Under Settings->Global Share settings you can set a Min Free Space value for the cache drive.    When the free space drops below this value then writes to user shares will bypass the cache and go straight to the array.

 

Note that this will not have any effect on dockers that are configured to use /mnt/cache as this is bypassing the User Share System so can still fill up the cache.

  • Thanks 1
  • Upvote 1
Link to comment
Just now, itimpi said:

Under Settings->Global Share settings you can set a Min Free Space value for the cache drive.    When the free space drops below this value then writes to user shares will bypass the cache and go straight to the array.

 

Note that this will not have any effect on dockers that are configured to use /mnt/cache as this is bypassing the User Share System so can still fill up the cache.

Ahh, that sounds like it.  AFAIK, my dockers don't have direct access to the cache (other than appdata) - they all go via shares.

Link to comment
  • 2 weeks later...

Hey, make your download path a extra share.

 

Set it to cache: yes (so it uses cache, if possible)

Then use 

 

#!/usr/bin/php
<?PHP

$moveAt = 80;    # Adjust this value to suit.

$diskTotal = disk_total_space("/mnt/cache");
$diskFree = disk_free_space("/mnt/cache");
$percent = ($diskTotal - $diskFree) / $diskTotal * 100;

if ( $percent > $moveAt ) {
  exec("/usr/local/sbin/mover");
}
?>

 

in the plugin user scripts and set it to run every minute  (0 * * * *)

 

This way you use your cache, but when it gets full it will transfer files from SSD to HDD. So theoreticle it shouldnt fill up.

  • Upvote 1
Link to comment

Thanks for that @nuhll - I've been looking at something similar, but I couldn't get to the bottom of whether it was OK to leave the regular mover running.  Whilst I want it to kick in at - say - 80%, I also want it to run overnight as well (otherwise things might stay on there unnecessarily long).

 

The other mover thing I was looking into was a notification if a file couldn't be moved due to space (eg, new/upgraded TV episodes onto a drive that has since been filled).

 

Link to comment

As far as i know this doesnt change anything other.


So if you let ur mover run at midnight (like i do), then it will do this anyway of the script above.

 

The move to hdd only happens when SSD is full, so exactly what you want.. :) (or if the files are not moved away from temp download until midnight)

 

And even if it gets moved to hdd, its np, you move the file to your archive and then it gets delted from hdd or sdd, wherever it is.

Edited by nuhll
Link to comment

No, I meant the first part...

 

- drive hits +80% full

- mover triggered, may take 20 minutes

- in that time, the script might try and start the mover again after the first minute as it might still be over 80%

- or the official mover might schedule at midnight whilst it's still running

 

If the mover at  exec("/usr/local/sbin/mover") only starts if it's not running, all good :)

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.