Example #1
0
    def getConsumerById(self, id):
        consumer = None
        if CacheKeys.useCache():
            try:
                consumer = cache.get(CacheKeys.getConsumerIdKey(str(id)))
            except:
                pass

        if consumer is None:
            print "getting consumer from db"
            consumer = Consumer.objects.get(id=id)
            if CacheKeys.useCache():
                cache.set(CacheKeys.getConsumerIdKey(str(id)), consumer, None)
        return consumer
Example #2
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
Example #3
0
    def getClientByToken(self, token):
        client = None
        if CacheKeys.useCache():
            try:
                client = cache.get(CacheKeys.getClientTokenKey(token))
            except:
                pass

        if client is None:
            print "getting client from db"
            client = Client.objects.get(token=token)
            if CacheKeys.useCache():
                cache.set(CacheKeys.getClientTokenKey(client.token), client, None)
        return client
Example #4
0
    def getClientById(self, id):
        client = None
        if CacheKeys.useCache():
            try:
                client = cache.get(CacheKeys.getClientIdKey(str(id)))
            except:
                pass

        if client is None:
            print "getting client from db"
            client = Client.objects.get(id=id)
            if CacheKeys.useCache():
                cache.set(CacheKeys.getClientIdKey(str(id)), client, None)
        return client
Example #5
0
    def getConsumerPrefs(self, id):
        prefs = None
        if CacheKeys.useCache():
            try:
                prefs = cache.get(CacheKeys.getConsumerPrefsByIdKey(str(id)))
            except:
                pass

        if prefs is None:
            print "getting ConsumerPrefs from db"
            prefs = ConsumerPrefs.objects.all().filter(consumerId=id)
            if CacheKeys.useCache():
                cache.set(CacheKeys.getConsumerPrefsByIdKey(str(id)), prefs, None)
        return prefs
Example #6
0
    def getCardByNum(self, cardNum):
        card = None
        if CacheKeys.useCache():
            try:
                card = cache.get(CacheKeys.getCardNumKey(cardNum))
            except:
                pass

        if card is None:
            print "getting card from db"
            card = ConsumerCard.objects.get(cardNum=cardNum)
            if CacheKeys.useCache():
                cache.set(CacheKeys.getCardNumKey(card.cardNum), card, None)
        return card
Example #7
0
    def getConsumerAggs(self, id):
        consumerAggs = None
        if CacheKeys.useCache():
            try:
                consumerAggs = cache.get(CacheKeys.getConsumerAggsByIdKey(str(id)))
            except:
                pass

        if consumerAggs is None:
            print "getting consumerAggs from db"
            consumerAggs = ConsumerAgg.objects.all().filter(consumerId=id)
            if CacheKeys.useCache():
                cache.set(CacheKeys.getConsumerAggsByIdKey(str(id)), consumerAggs, None)
        return consumerAggs
Example #8
0
    def getCategoryByMccCode(self, mccCode):
        txnCategory = None
        if CacheKeys.useCache():
            try:
                txnCategory = cache.get(CacheKeys.getCategoryByMccCodeKey(str(mccCode)))
            except:
                pass

        if txnCategory is None:
            print "getting txnCategory from db"
            txnCategory = TxnCategory.objects.get(mccCode=mccCode)
            if CacheKeys.useCache():
                cache.set(CacheKeys.getCategoryByMccCodeKey(str(mccCode)), txnCategory, None)
        return txnCategory
Example #9
0
    def getMerchantByUuid(self, uuid):
        print "getting merchant from cache.."
        merchant = None
        if CacheKeys.useCache():
            try:
                print "getting consumer from cache"
                merchant = cache.get(CacheKeys.getMerchantUuidKey(str(uuid)))
                print "after getting consumer from cache"
            except:
                pass

        if merchant is None:
            print "getting merchant from db"
            merchant = Merchant.objects.get(uuid=uuid)
            if CacheKeys.useCache():
                cache.set(CacheKeys.getMerchantUuidKey(str(uuid)), merchant, None)
        return merchant
Example #10
0
 def setConsumer(self, id):
     consumer = Consumer.objects.get(id=id)
     cache.set(CacheKeys.getConsumerIdKey(str(id)), consumer, None)
Example #11
0
 def setDevice(self, id):
     consumerDevice = ConsumerDevice.objects.get(id=id)
     cache.set(CacheKeys.getConsumerDeviceTokenKey(consumerDevice.deviceToken), consumerDevice, None)
Example #12
0
 def setCard(self, cardId):
     card = ConsumerCard.objects.get(id=cardId)
     cache.set(CacheKeys.getCardNumKey(card.cardNum), card, None)
Example #13
0
 def setConsumerPrefs(self, id):
     consumerPrefs = ConsumerPrefs.objects.all().filter(consumerId=id)
     cache.set(CacheKeys.getConsumerPrefsByIdKey(str(id)), consumerPrefs, None)