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

Add persist driver cache #1555

Merged

Conversation

marcheffels
Copy link
Contributor

@marcheffels marcheffels commented May 16, 2024

⚡ PowerGrid - Pull Request

Welcome and thank you for your interest in contributing to our project!. You must use this template to submit a Pull Request or it will not be accepted.


Motivation

  • Bug fix
  • Enhancement
  • New feature
  • Breaking change

Description

This Pull Request adds persist driver cache.

If a project has many tables, the cookie header will be going to large.

Related Issue(s): #_____.

Documentation

This PR requires Documentation update?

  • Yes
  • [] No
  • I have already submitted a Documentation pull request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest:

    private function getPersistDriverStoreConfig(): string
    {
        return strval(config('livewire-powergrid.persist_driver_store'));
    }

and perhaps we could profit and improve code readability with:

        $jsonState = strval(json_encode($state));

        match ($this->getPersistDriverConfig()) {
            'session' => Session::put($this->getPersistKeyName(), $jsonState),
            'cache'   => Cache::store($this->getPersistDriverStoreConfig())->put($this->getPersistKeyName(), $jsonState),
            default   => Cookie::queue($this->getPersistKeyName(), $jsonState, now()->addYears(5)->unix())
        };

@dansysanalyst
Copy link
Member

Hi @marcheffels,

Thanks for the PR!

Could you please run composer pint:fix ?

@marcheffels
Copy link
Contributor Author

Hi @dansysanalyst,

very gladly, thx

@luanfreitasdev
Copy link
Collaborator

Thank you @marcheffels

@luanfreitasdev luanfreitasdev merged commit 211426d into Power-Components:5.x May 22, 2024
21 checks passed
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

Successfully merging this pull request may close these issues.

None yet

3 participants