Use redis to cache your models.
The way I will cache my instances will be as follows:
1 - Make sure you get one item at a time. For example: Model.objects.get (foo = 'bar'), and each time you use the foo attribute to get the model from the database. This will be used to ensure that data becomes invalid later.
2-Override save () method and make sure it saves data to the cache using the foo attribute.
eg:
class Model(model.Model): foo = models.CharField() bar = models.CharField() def save(self, *args, **kwargs): redis.set(foo, serialize_model()) super(Model, self).save(*args, **kwargs) def serialize_model(): return serilized_object
3-Override get method to get the serialized object before deleting the database.
eg:
class Model(model.Model): ... def get(self, *args, **kwargs): if redis.get(self.foo): return redis.get(self.foo) else: return super(Model).get(*args, **kwargs)
4. Override the delete method to remove the cache if the instance was deleted or deleted.
eg
class Model(model.Model): ... def delete(self,*args, **kwargs): redis.delete(self.foo) super(Model, self).delete(*args, **kwargs)
Replace the model class with your model, in this case it will be a ticket type
One thing, I assume that you will not touch the database outside of your Django application. If you use raw sql anywhere else, this will not work.
Look for redis functions on your website, they have a function to remove, install and retrieve. If you use a different caching method. See how to install, receive, and remove.