예제 #1
0
    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
예제 #2
0
 def setDevice(self, id):
     consumerDevice = ConsumerDevice.objects.get(id=id)
     cache.set(CacheKeys.getConsumerDeviceTokenKey(consumerDevice.deviceToken), consumerDevice, None)