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 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
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
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
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
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
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
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
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