I am working on a Django project and have some instances of a class. I cached instance A with key 'A', and create a new instance B in another request. The thing is instance B now has data of instance A. When I change instance B's data and get instance 'A' from cache, instance A's data changes too.
I guess this has something to do with python's reuse mechanism. Anyone know how to fix this problem?
Edit 1: This is how I create a class using its name:
def create_model_by_name(name):
name = name.capitalize()
klass = globals()[name]
instance = klass()
return instance
I use django.core.cache.cache to cache objects.
This is some data I store in my class. I have some classes inherited from Abstract.
class Abstract:
class_name = 'unknown'
prev_text = []
props = {}
waiting_state = ''
output = ''
props_alias = {}