Code Monkey home page Code Monkey logo

Comments (12)

reinink avatar reinink commented on September 13, 2024

Not at the moment, no. I had no idea anyone would ever want to that, but that makes sense if you're using Varnish. Can you leave this with me to add a new method for this? For the time being maybe just save the cached files to sys_get_temp_dir()?

from glide.

sagikazarmark avatar sagikazarmark commented on September 13, 2024

I probably found the solution. IIRC there is a null adapter in flysystem. That might work.

from glide.

reinink avatar reinink commented on September 13, 2024

Haha, yep, that would probably work too. ;)

from glide.

xtrasmal avatar xtrasmal commented on September 13, 2024

Is this repo free for pull requests? I'd like to add something like this:

Current situation:

    /**
     * Get the source file system.
     * @return FilesystemInterface The source file system.
     */
    public function getSource()
    {
        $source = null;

        if (isset($this->config['source'])) {
            $source = $this->config['source'];
        }

        if (is_string($source)) {
            return new Filesystem(new Local($source));
        }

        if ($source instanceof FilesystemInterface) {
            return $source;
        }

        throw new InvalidArgumentException('Invalid `source` parameter.');
    }

Preferred situation:

    /**
     * Get the source file system.
     * @return FilesystemInterface The source file system.
     */
    public function getSource()
    {
        $source = null;

        if (isset($this->config['source'])) {
            $source = $this->config['source'];
        }

        if (is_string($source)) {
            return new Filesystem($this->adapter($source, $adapterclass));
        }

        if ($source instanceof FilesystemInterface) {
            return $source;
        }

        throw new InvalidArgumentException('Invalid `source` parameter.');
    }
// Add the source and the adapter, f.e. 'League\Flysystem\Adapter\Null'
    public function adapter($source, $class)
    {
        return new $class($source);
    }

from glide.

reinink avatar reinink commented on September 13, 2024

Hi @xtrasmal, can you explain to me exactly what you're trying to do? I'm sort of confused. If you're simply trying to pass the Null adapter to the Glide factory you can just do this:

$server = League\Glide\ServerFactory::create([
    'source' => 'path/to/source/folder',
    'cache' => new League\Flysystem\Adapter\Null(),
]);

from glide.

 avatar commented on September 13, 2024

Hi @reinink, passing an instance of Flysystem's NullAdapter (there is no Null) as you suggested does not work:

InvalidArgumentException in ServerFactory.php line 90:
Invalid `cache` parameter.

I believe it has to do with the following check on line 86 of ServerFactory.php just before the InvalidArgumentException gets thrown:

if ($cache instanceof FilesystemInterface) {
    return $cache;
}

Because: NullAdapter extends AbstractAdapter which implements AdapterInterface which extends ReadInterface. So it is not an instance of FilesystemInterface.

I believe this is a bug as there is currently no way to turn off caching, which I would like to so as to let a CDN handle caching managed by headers.

Thoughts?

from glide.

reinink avatar reinink commented on September 13, 2024

Yeah, agreed, I'll add the option to disable the cache in an upcoming release.

from glide.

shyam-achuthan avatar shyam-achuthan commented on September 13, 2024

Is there a way to delete the cached files for a particular image?
Say i have a profile image getting uploaded to the S3 which is scaled at different ui, when the user changes the image it wont change the image endpoints but glide actually serves the old cached images based on old requests.

from glide.

 avatar commented on September 13, 2024

@shyam-achuthan What you're describing is cache invalidation; something that is discussed in another issue.

From my understanding, there is currently no cache invalidation handling in Glide. I submitted a pull request to allow disabling of the cache so that caching - and invalidation - could simply be handled by another layer like a CDN (e.g. Amazon CloudFront) or a reverse proxy (e.g. Nginx).

from glide.

xtrasmal avatar xtrasmal commented on September 13, 2024

cache invalidation 👍

from glide.

xtrasmal avatar xtrasmal commented on September 13, 2024

That is my problem

Op 20 mrt. 2015 om 14:17 heeft "Shyam Achuthan" [email protected] het volgende geschreven:

Is there a way to delete the cached files for a particular image?
Say i have a profile image getting uploaded to the S3 which is scaled at different ui, when the user changes the image it wont change the image endpoints but glide actually serves the old cached images based on old requests.


Reply to this email directly or view it on GitHub.

Met vriendelijke groet, With kind regards,

Xander Smalbil

Netbulae Virtualization Experts


Tel: 053 20 30 270  [email protected]    Staalsteden 4-3A    KvK 08198180
Fax: 053 20 30 271  www.netbulae.eu     7547 TA Enschede    BTW NL821234584B01

from glide.

reinink avatar reinink commented on September 13, 2024

Hey all, I've finally got a good solution to this cache disabling problem. See #56.

from glide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.