Laravel Cache: Bad Data

I have two functions that look almost the same and are called on the right one after the other as AJAX requests from a JavaScript function.

/**
     * get all Airports for autocomplete
     */
    public function getAirports(){
        if(Cache::has('airports')){
            return Cache::get('airports');
        }

        $airportModel = new Airport;

        $airports = json_encode($airportModel -> _getForAutocomplete('iata_faa_code'));

        Cache::put('airports', $airports, 600);

        return $airports;
    }

    /**
     * get all Countries for autocomplete
     */
    public function getCountries(){
        if(Cache::has('countries')){
            return Cache::get('countries');
        }

        $countryModel = new Country;

        $countries = json_encode($countryModel -> _getForAutocomplete('two_letter_code'));

        Cache::put('countries', $countries, 600);

        return $countries;
    }

Now, when I first go to the page, I get the data correctly (since it is not cached yet). If I go to the page a second time, I get countries, but for airports I get the following error and don’t understand why.

{"error":{"type":"Illuminate\\Encryption\\DecryptException","message":"Invalid data.","file":"C:\\xampp\\htdocs\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Encryption\\Encrypter.php","line":132}}

I found out that he had to do something with the Googling cache and deleting the Cache part. I would be very happy if someone could help me with this.

By the way, I use the database as a cache driver.

Regards, Marcel

+4
source share
1 answer

, - . , $ .

MySQL, .

Laravel . , mediumText longText.

+5

Source: https://habr.com/ru/post/1583744/


All Articles