-
Notifications
You must be signed in to change notification settings - Fork 225
do I need to modify this to use it with jenssegers/laravel-mongodb ? #57
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
Comments
I've gone ahead and made a duplicate of your CachedModel and called ot MongoCachedModel, Then inside that class I replaced the extend Model by extend Eloquent And added use Jenssegers\Mongodb\Eloquent\Model as Eloquent; That's all that was needed to get it to work with mongodb models Except that now I can't use the artisan flush command on that model because it's not an instance of "CachedModel" Can you think of a more elegant way to handle this? |
I also ran into one problem so far when working with mongodb models. Unlike with mysql, sometimes the values are arrays themselves and that triggered a Array to String conversion error on these lines inside the CacheKey
I was able to fix it by changing it to
|
Interesting, I will see about adding this. If you can submit a PR that would expedite things, but it sounds like a good idea. |
Update: Doh.. I had totally forgot I had done another small change on my dev only.. inside the vendor files.. ugh.. and hadn't pushed it to my fork.. It was this change in the Cachable trait:
hey @mikebronner I'm hoping maybe you can think of something here... what I mentioned above is really the only small change I needed to do in order to get it to work with my mongodb models. This was working perfectly on my DEV environment. Mongo models were being invalidated exactly as you'd expect a mysql model to.. no biggie but then tonight I deployed my changes to production.. and I'm baffled. Mysql models are being invalidated, but not the mongo ones! And there are no errors being thrown at all. I verified that I'm loading my fork correctly with that small change you see above. I cleared all caches.. opcache.. everything.. multiple times. I added \Log::debug in my _CachedMongoModel file which is a clone of CachedModel as I mentioned above. I added logging on the update/saved events and can confirm that it's going in there.. and it's executing the $instance->flushCache();.. and it's not throwing any errors but it won't flush the darn mongo models I even connected through Medis.. a pretty cool Redis GUI client, and I compared the tag names on both my DEV and production.. and the tag names are the same. If I use the command line to flush models.. it works on DEV for both mysql and mongo tags.. but on Live it only works on mysql models I made myself my own flush command btw because yours requires that the model be an instance of CachedModel so I just commented those out. my .env file is almost the same on dev and live.. redis is used for all the drivers.. I really don't think this is an environment issue.. but maybe some obscure difference.. I just spent an hour trying to debug this before I had to revert Anyway I am really out of ideas of why it isn't able to flush the mongo models on live.. the tags look identical.. ?? if you have any idea you'd really be helping me out here! Thanks! |
Fixed in version 0.2.30. Please re-open if still a problem. |
I am using jenssegers/laravel-mongodb and using hybrid relations between mysql models and mongodb models
the mongodb models however rather than extend laravel's default model, extend a special wrapper model of sorts
a lot of model-related packages on github do work out of the box with mongodb models but I'm not sure how to use this one since it depends on extending a different model
any chance you could have a quick look at jenssegers/laravel-mongodb and see if there's a quick and easy solution to using it with your package?
thanks much!
The text was updated successfully, but these errors were encountered: