Comments (20)
If there are multiple ways of implementing the CacheCleanup, it could be integrated by using the Strategy Pattern.
Some default strategy like OlderThanCleanup
or NoCleanup
can then be provided by glide.
from glide.
@h4cc That's probably a good idea actually.
I've thought of another way of doing this. Glide could keep an access log in the cache file system, which could be then used by a cleanup job later. This access log would provide access dates in addition to just creation dates.
from glide.
@reinink and what about when the source image changes?
For example, I have a filebrowser where I can resize/rotate etc some files. But changes aren't shown because the file is cached.
A solution could be checking the time the file has changed and invalidate the cache if needed, but this causes extra calls..
from glide.
I'm actually like the idea I'm seeing in PR #60.
Basically, we could allow folks to override how the cached filename is generated. This would allow you to group all manipulations for a specific source image into a specific folder. Then, if you delete that source folder, you can easily delete all the cached variations. Something like this:
$server->setCachePathFilter(function (Request $request, $path) {
// modify $path
return $path;
});
At this point I'm just not sure a closure is the best way (it seems a little complicated), or if we just abstract the cache path generation to a new class, with a interface.
Whatever the case, I think I'm going to do something here. I just need to work out the simplest way, and do some testing.
from glide.
Or, another idea, why don't we just automatically organized the cached images into folders, and the folders will simply be the source name. For example:
// Source:
/source/kayaks.jpg
/source/logos/logo.png
// Cache:
/cache/kayaks.jpg/md5-cache-filename
/cache/kayaks.jpg/md5-cache-filename
/cache/kayaks.jpg/md5-cache-filename
/cache/logos/logo.png/md5-cache-filename
/cache/logos/logo.png/md5-cache-filename
/cache/logos/logo.png/md5-cache-filename
That would make it really easy to delete the cache for any particular source image. For example:
$cache->deleteDir('kayaks.jpg');
Thoughts?
from glide.
I like that ;-)
This storage structure and a delteCache($source) method on the Server class.
from glide.
That would be great, a way to clear the cache only for a specific image it's the missing piece for us to start using Glide in production!
from glide.
@schmidex @ingro Glad you like! Coming soon to the next release of Glide. Hopefully within the next few weeks.
from glide.
why don't we just automatically organized the cached images into folders, and the folders will simply be the source name.
👍 💯
from glide.
I really like the idea of being able to clean up the cache files using folders by source name. Has there been any progress on this enhancement yet? Thanks for the great library!
from glide.
@joshrhykerd Glad you like! And yes, this feature has been built and will be available as soon as I release version 1.0, which is really any day now. You can see this feature mentioned in the WIP docs, here.
from glide.
I hate to ask, but there isn't any development branch or anything anywhere with this functionality already built in is there? I'm in a slight predicament now where I neeeeeed this ability. lol Again thanks again for this great library!
from glide.
@joshrhykerd For sure, just use dev-master
. In your Composer file:
{
"require": {
"league/glide": "dev-master"
}
}
Note that you'll likely also want to use a framework adapter, to make getting responses back easier. I originally had these built right in, but I recent split them all into separate packages. Add the framework adapter of your choice in the same way:
{
"require": {
"league/glide-symfony": "dev-master"
}
}
And then just follow the docs for how to setup the response factory. It will look something like this:
$server = League\Glide\ServerFactory::create([
'response' => new League\Glide\Responses\SymfonyResponseFactory()
]);
Just be aware that you're using development code. Be sure to switch from dev-master
to a tagged release as soon as one is available. Good luck!
from glide.
@reinink Thanks!
from glide.
@reinink I'm not sure if this is a bug or not, but when I call
$server->deleteCache($filename);
with just the source filename it doesn't seem to work. I have to also include the server cache_path_prefix.
$server->deleteCache($server->getCachePathPrefix() . DS . $filename);
Should it automatically be including the cache_path_prefix for me? or am I doing something wrong?
from glide.
Hmm, maybe it's broken. It was working, but I still need to write tests for this. Honestly, for now you can just use Flysystem directly. For example:
$cache->deleteDir('path/to/directory/to/delete');
from glide.
This feature should now be fixed. (5ededae)
from glide.
Closing this ticket. These changes have been merged into the master branch and will be tagged shortly when I release v1.0
! Hopefully not long now.
from glide.
@reinink Looking forward to the release of version 1.0,and when ? :D
from glide.
The method deleteCache not works with me.
I did need to do this way:
$server = app(GlideServer::class);
// $server->deleteCache($imagePath); // not works
// $server->deleteCache($server->getCachePathPrefix() . "/" . $imagePath); // not works
Storage::disk('images')->deleteDirectory($server->getCachePathPrefix() . "/" . $imagePath); // works
from glide.
Related Issues (20)
- [ feature ] Save resized files to another directory with different link
- Create custom 404 route? HOT 1
- Repeat watermarks
- Mockery error in League\Glide\ServerTest::testMakeImageFromSource HOT 1
- Could not find the image error in Laravel
- how to get with and height of picture after glide traitement HOT 2
- Image will not manipulate when using crop focus zoom and when resize dimensions are equal to original asset dimensions
- ImagickException: NoDecodeDelegateForThisImageFormat `PNG' HOT 1
- Black border added to images during processing HOT 3
- generate a temporarySignedRoute
- Feature request for base_url option to be regular expression
- HEIC format support HOT 2
- We need upgrading to intervention/image ^3 please HOT 2
- Differences in the use of fit=fill and fit=fill-max HOT 3
- Cannot make it working in RAW PHP... pls help 🙇♂️
- upgrade intervention/image to V3 HOT 1
- locale srouce and cache with cdn setting
- not working with laravel 11 HOT 1
- Support intervention/image:^3 HOT 4
- 3.x release date HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glide.