Git Product home page Git Product logo

laravel-cacheable's Issues

getCacheLifetime return type error

Type error: Return value of Rinvex\Attributes\Models\AttributeEntity::getCacheLifetime() must be of the type integer, null returned

because

    public function getCacheLifetime(): int
    {
        return $this->cacheLifetime;
    }
    public function resetCacheConfig()
    {
        $this->cacheDriver = null;
        $this->cacheLifetime = null;

        return $this;
    }

set cacheLifetime to null

data folder inside framework/cache/ not created after cache:clear

Hi,

i have a question regarding writing the rinvex.cacheable.json file into the cache folder.

My Setup:

I basically got the rinvex/attributable package loaded and the rinvex/cacheable is used through it.

Problem:

Whenever you run artisan cache:clear and run anything afterwards like calling a controller that loads a model implementing the attributable behavior, creating the cache file fails.

file_put_contents(/Users/.../storage/framework/cache/data/rinvex.cacheable.json): failed to open stream: No such file or directory
```

The referring Code is in `cacheable/src/CacheableEloquent.php:99`
```
protected static function storeCacheKey(string $modelName, string $cacheKey)
    {
        $keysFile = storage_path('framework/cache/data/rinvex.cacheable.json');
        $cacheKeys = static::getCacheKeys($keysFile);
        if (! isset($cacheKeys[$modelName]) || ! in_array($cacheKey, $cacheKeys[$modelName])) {
            $cacheKeys[$modelName][] = $cacheKey;
            file_put_contents($keysFile, json_encode($cacheKeys));
        }
    }
```

Actually if the data folder inside framework/cache is not present creating the file will fail.
Manually creating the folder and everything is fine.

My Question
---------------
Shall i provide a PullRequest that simply checks if the folder exists and creates it?

Best
null9beta

laravel 5.5: Your requirements could not be resolved to an installable set of packages.

There is no support for 5.5?

Problem 1
    - Installation request for rinvex/subscriptions dev-develop -> satisfiable by rinvex/subscriptions[dev-develop].
    - rinvex/subscriptions dev-develop requires rinvex/cacheable dev-develop -> satisfiable by rinvex/cacheable[dev-develop] but these conflict with your requirements or minimum-stability.

I also tried to install v0.0.2 same problem.

Any advice?
Thanks a lot in advance.

How to disable cache for RAND()

I have a query builder using inRandomOrder() method.
But this cache the result. I want ignore cache if have RAND() query.

$posts = Post::inRandomOrder()->take(10)->get();

Cached relations are not invalidated

CacheableEloquent caches relations data, but does not invalidate cache when the related models change. There is no indications in the documentation of how relationships are treated or if there are strategies to make caching work for relations.

Question: Should work on PHP 5.6 ?

Hi, this seems to be great package !

Are you planning to support 5.6+ version of PHP. I am running LV 5.3 but wasn't able to install this on it because it enforces v7 of php.

Thanks

Set cache driver and cache lifetime

Hi. Not really an issue but I'm not figuring out how to set cache driver and cache lifetime.
The cache works ok with the default cache driver.

Thanks in advance

Overriding $cacheLifetime

Hi!

I'm using this trait in a model where the default lifetime of -1 doesn't make sense, so I'm trying to change it to another number by adding protected $cacheLifetime = 10; into my class definition. However, it keeps FatalErrorException:ing on me and spitting back: App\Model\<myModel> and Rinvex\Cacheable\CacheableEloquent define the same property ($cacheLifetime) in the composition of App\Model\<myModel>..

Any suggestions?

Forget cache all models

Hi, I have a process that makes a lot of changes.

How can I forget all models cache?

Thanks!

Doesn't work with factories

When running factories, the data will be empty:

<?php

namespace Database\Seeders\Pages;

use App\Pages\Entities\Page;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;

class PagesTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Model::unguard();

        factory(Page::class, 500)->create();

        //Page::forgetCache();

        dd(Page::all());
    }
}

this will return an empty collection even though there's rows in the database.

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.