def getConsumerDeviceByToken(self, token): consumerDevice = None if CacheKeys.useCache(): try: consumerDevice = cache.get(CacheKeys.getConsumerDeviceTokenKey(token)) except: pass if consumerDevice is None: print "getting consumerDevice from db" consumerDevice = ConsumerDevice.objects.get(deviceToken=token) if CacheKeys.useCache(): cache.set(CacheKeys.getConsumerDeviceTokenKey(consumerDevice.deviceToken), consumerDevice, None) return consumerDevice
def setDevice(self, id): consumerDevice = ConsumerDevice.objects.get(id=id) cache.set(CacheKeys.getConsumerDeviceTokenKey(consumerDevice.deviceToken), consumerDevice, None)