GithubHelp home page GithubHelp logo

Comments (7)

hen3b182 avatar hen3b182 commented on May 26, 2024

So i have excluded LadaCacheTrait from UserInfo and it started working again. But now this Model doesn't get cached.

from lada-cache.

spiritix avatar spiritix commented on May 26, 2024

If you want to exclude certain tables, please do so using the provided configuration option: https://github.com/spiritix/lada-cache/blob/master/config/lada-cache.php#L76
The trait should always be included in all models, otherwise it might result in bugs.

Regarding the issue you mentioned initially, was the data actually updated in the database? Is the proper data returned once you truncated the cache?

from lada-cache.

hen3b182 avatar hen3b182 commented on May 26, 2024

i included the Trait again, but whenever i update the field, the cache didnt get refreshed.

it starts like this:
$user->user_info()->first_name = test1

i update like this:

$user_info = $user->user_info()->updateOrCreate(['user_id' => 1], [
	'first_name' => 'test2'
]);

When i now echo $user->user_info()->first_name it still says test1, and in the database i have test2. So it got updated all fine, but not in the cache.

I have now included in the config:
'exclude-tables' => ['user_infos'],

and now it works. But i guess it should not be like this ;)

from lada-cache.

spiritix avatar spiritix commented on May 26, 2024

No, it should not be like this :) For further debugging I would need to see the output of the Debugbar, specifically of the Queries tab and the Lada tab.

from lada-cache.

hen3b182 avatar hen3b182 commented on May 26, 2024

For some odd reason it started acting normal again. If it happens again, i report here. How can i share the debugbar info with you?

from lada-cache.

spiritix avatar spiritix commented on May 26, 2024

All right, feel free to re-open this in case it happens again. You can send me the screenshots via email or post a link here.

from lada-cache.

hen3b182 avatar hen3b182 commented on May 26, 2024

@spiritix , another one,

I have 2 models:

  • User
class User extends Authenticatable
{

	// ...
    use \Spiritix\LadaCache\Database\LadaCacheTrait;
	
    public function notifications()
    {
        return $this->hasMany(Notification::class);
    }
	
	// ...
}
  • Notification
class Notification extends Model
{
    use \Spiritix\LadaCache\Database\LadaCacheTrait;
	// ...

    public function user()
    {
        return $this->belongsTo(User::class);
    }
	
	// ...
}

For testing i used this code:

    foreach(auth()->user()->notifications as $notification){        
        if(!$notification->read_at){
            echo $notification->id.'<br />';
        }
        if($notification->id==2203){
            $notification->read_at = Carbon::now();
            $notification->save();
        }
    }

But Cache is not getting updated. I keep getting notification id 2203.

see screenshots:
11-ladaNotificationsHit

11-ladaNotificationsQueries

11-withUpdateSaveNotificationQuery

11-withUpdateSaveNotificationQueryAgain

11-phpMyAdmin

from lada-cache.

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.