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

UpdatedAt causing cache miss #145

Closed rahulvgmail closed 6 years ago

rahulvgmail commented 8 years ago

most of my code is straight out of documentation.

only thing i changed is this

class CustomListKeyConstructor(DefaultKeyConstructor): updated_at = UpdatedAtKeyBit() all_query_params = QueryParamsKeyBit()

if i comment out " updated_at = UpdatedAtKeyBit()" values are picked form cache. if i add that, it always misses the cache.

the request format is

http://52.34.132.24/travelogue/resttripnote/?limit=5&offset=25

this is updatedAt key bit function

class UpdatedAtKeyBit(KeyBitBase): def get_data(self, **kwargs): key = 'api_updated_at_timestamp' value = cache.get(key, None) if not value: value = datetime.datetime.utcnow() cache.set(key, value=value) return force_text(value)