Code Monkey home page Code Monkey logo

Comments (10)

mikebronner avatar mikebronner commented on May 18, 2024 1

@hendra1 this should now be fixed in 0.2.41. Thank you so much for reporting this! The insert and update methods hadn't been accounted for yet. Please let me know how this update works for you.

from laravel-model-caching.

mikebronner avatar mikebronner commented on May 18, 2024

@hendra1 thanks for reporting this. Could you test again using the latest version of this package: 0.2.40? Thanks!

from laravel-model-caching.

hendra1 avatar hendra1 commented on May 18, 2024

Yes I did.. and the result is still same.

from laravel-model-caching.

mikebronner avatar mikebronner commented on May 18, 2024

Thanks, I will try to replicate it.

from laravel-model-caching.

mikebronner avatar mikebronner commented on May 18, 2024

Hi @hendra1,

Regarding your question about having a way to invalidate in the controller: that is not planned. The package should invalidate.

I am unable to recreate the problem with the following test:

    public function testModelCacheDoesInvalidateWhenNoCooldownPeriod()
    {
        $authors = (new Author)
            ->get();

        factory(Author::class, 1)->create();
        $authorsAfterCreate = (new Author)
            ->get();
        $uncachedAuthors = (new UncachedAuthor)
            ->get();

        $this->assertCount(10, $authors);
        $this->assertCount(11, $authorsAfterCreate);
        $this->assertCount(11, $uncachedAuthors);
    }

The test passes. Could you provide the queries you are running, specifically the initial query, the insert query, and the third query that is not getting the updated values?

Thanks!

from laravel-model-caching.

mikebronner avatar mikebronner commented on May 18, 2024

I found an issue, it has to do with insert. (Sorry I didn't test that right away, mia culpa. :) ) This test exposes it:

    public function testInsertInvalidatesCache()
    {
        $authors = (new Author)
            ->get();

        $newAuthor = (new Author)
            ->insert([
                'name' => 'Test Insert',
                'email' => '[email protected]',
            ]);
        $authorsAfterInsert = (new Author)
            ->get();
        $uncachedAuthors = (new UncachedAuthor)
            ->get();

        $this->assertCount(10, $authors);
        $this->assertCount(11, $authorsAfterInsert);
        $this->assertCount(11, $uncachedAuthors);
    }

I will work on fixing this ASAP!

from laravel-model-caching.

hendra1 avatar hendra1 commented on May 18, 2024

Hi Mike

Thanks for the update.. now it's work :)

from laravel-model-caching.

mikebronner avatar mikebronner commented on May 18, 2024

Awesome! That's great to hear. :) please let me know if you run into any other issues .

from laravel-model-caching.

mrahmadt avatar mrahmadt commented on May 18, 2024

I'm using
DB::insert();
to insert hundreds of records (this provide faster insert than MODEL::insert, any chance I can invalidate the cache?

from laravel-model-caching.

mikebronner avatar mikebronner commented on May 18, 2024

Hi @mrahmadt, could you open a new issue for this? Thanks!

from laravel-model-caching.

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.