Using the decorator with classes
Hi,
if one wants to use the decorator with classes then one runs into the following issue:
The first arg of a function is "self", which will return the memory address if one calls "str()" on it.
This can be fixed adding the "str" magic methods to one's class:
def __str__(self):
return "class_name"
A more general fix would be better in my opinion, basically, the "key" generation has to be altered:
Right now I have no better idea other than:
[str(i) for i in args if not "object at 0x" in str(args[0])]
Not sure if it would be a better approach to force the user to set the "str" by throwing an exception.
Let me know what you think.
Thank you for pointing out this issue, it was the first thing I ran into when trying out this package. ;)
The flask-cache module solves this by asking the user to define __repr__ of any returned objects or on the class of any methods which are cached