Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only flush cache when delete() returns a count #435

Open
m-lotze opened this issue Aug 19, 2022 · 0 comments
Open

Only flush cache when delete() returns a count #435

m-lotze opened this issue Aug 19, 2022 · 0 comments

Comments

@m-lotze
Copy link

m-lotze commented Aug 19, 2022

The two methods delete and forceDelete in Buildable trait should imho only flush the cache, if the parent methods return an int > 0. Right now, the cache is flushed every time, even when the query did not actually deleted records from the database.

public function delete()
{
    $result = parent::delete();

    if ($result) {
        $this->cache($this->makeCacheTags())->flush();
    }

    return $result;
}
@m-lotze m-lotze changed the title Only flush cache, when delete() returns a count Only flush cache when delete() returns a count Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant