craftcms / element-api

Create a JSON API/Feed for your elements in Craft.
MIT License
498 stars 57 forks source link

Cache not clearing #153

Closed zizther closed 3 years ago

zizther commented 3 years ago

Description

Since updating to v2.8 from 2.7 I've noticed that the cache is no longer clearing after the time set. If i clear all caches via the CLI it will work.

Here is one example of what I have. In this example I am outputting a the current dat and time to illustrate that the cache is not expiring.

return [
    'elementType' => Entry::class,
    'one' => true,
    'cache' => 'PT1M', // 1 minute
    'transformer' => function(Entry $entry) {
        $date = date('d-m-y h:i:s');

        return [
            'date' => $date,
        ];
    },
];

Steps to reproduce

  1. Enable Element API, create an endpoint which includes the above and cache it for 1 minute
  2. View the endpoint to show the current date and time
  3. Wait longer than 1 minute, then view the endpoint again (the date and time don't refresh)

Additional info

brandonkelly commented 3 years ago

Thanks for reporting that! Just released v2.8.2 with a fix.