Open danielstocks opened 9 years ago
I was looking through the project test cases and I couldn't find anything covering the combination of using flask views in conjunction delete_memoized. Maybe I'm doing something really stupid here, but I'd like to know why this doesn't work:
delete_memoized
@views.route('/users/<id>') @cache.memoize(3600) def get_user(id): user = User.query.get_or_404(id) return jsonify(user.to_json()) def clear_cache(id): cache.delete_memoized(get_user, str(id)) clear_cache(1)
This will not delete the memoized function cache. But this will:
@cache.memoize(3600) def get_user_proxy(id): user = User.query.get_or_404(id) return jsonify(user.to_json()) @views.route('/users/<id>') def get_user(id): return get_user_proxy(str(id)) def clear_cache(id): cache.delete_memoized(get_user_proxy, str(id)) clear_cache(1)
Would be nice to get rid of the boilerplate code above :)
Thanks in advance.
I was looking through the project test cases and I couldn't find anything covering the combination of using flask views in conjunction
delete_memoized
. Maybe I'm doing something really stupid here, but I'd like to know why this doesn't work:This will not delete the memoized function cache. But this will:
Would be nice to get rid of the boilerplate code above :)
Thanks in advance.