chibisov / drf-extensions

DRF-extensions is a collection of custom extensions for Django REST Framework
http://chibisov.github.io/drf-extensions/docs
MIT License
1.47k stars 208 forks source link

DEFAULT_CACHE_RESPONSE_TIMEOUT - not being respected #96

Open rosscdh opened 9 years ago

rosscdh commented 9 years ago

Hey there, great extension! thanks for that

Having a strange issue with the response timeout never flushing. I have to restart uwsgi to get the cache flushed.

Current settings are.

REST_FRAMEWORK_EXTENSIONS = {
    'DEFAULT_CACHE_RESPONSE_TIMEOUT': 60 * 5
}

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
    }
}

As you can see I've taken the defaults but my cache never expires.

Any thoughts?

chibisov commented 9 years ago

Hi, could you try memcached backend? I believe it could be issue with in-memory caching.

rosscdh commented 9 years ago

Thanks @chibisov I've created a PR for a docs change: https://github.com/chibisov/drf-extensions/pull/97 appreciate the quick feedback. Switched to redis_cache and seems to work well.

rosscdh commented 9 years ago

Sorry this still seems to be an issue...

REST_FRAMEWORK_EXTENSIONS = {
    'DEFAULT_CACHE_RESPONSE_TIMEOUT': 60 * 5
}

CACHES = {
    'default': {
        #'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', # BUG with locmemcache for DRF-extensions dont use
        'BACKEND': 'redis_cache.RedisCache',
        'LOCATION': 'redis://blahblahblabh.cache.amazonaws.com/1',
    }
}

does not update at all.. :(

chibisov commented 9 years ago

Please, show me how you cache your views

rosscdh commented 9 years ago

@chibisov thanks caching like this

class PostsViewset(CacheResponseAndETAGMixin,
                                viewsets.ReadOnlyModelViewSet):
...
auvipy commented 8 years ago

valid? or close as invalid?