thephpleague / glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.
http://glide.thephpleague.com
MIT License
2.55k stars 199 forks source link

Handling cache in this particular situation #270

Closed theprobugmaker closed 4 years ago

theprobugmaker commented 4 years ago

I have two folders: temporary and permanent, when the user uploads the image first goes to a temporary folder and later we move those images to a permanent folder. I need to serve both the temporary and permanent folder images with glide functionalities but glide creates the cache with the path and folders. How can I disable caching for the temporary folder or when moving an image from the temporary I remove the cache before?

reinink commented 4 years ago

Hmmm, you might want to consider setting up two different Glide servers, once for each use case here. That way you can control where the files go. Also, you can disable the cache if needed. See here.

Also, I wouldn't try to reuse the cache between the two locations. I would simply have Glide recreate the cache at the new location.

Also, if you look in the advanced usage docs, you can see the deleteCache($path) function that you could use to delete the cache for a specific image.

Hope that helps.

theprobugmaker commented 4 years ago

By using the in memory caching is not actually disabling it right? I mean, it will be there allocating memory (won't that be a problem?). I think I thought about a new solution instead of having two folders (temporary and permanent). I will only have one, the difference is that when the user uploads an image it will create an image of Image model putting the records on the database, later I can create a job to look for orphan Image's and delete them both from the database and the system. I think it's a better solution than moving things around right?