def _get_data(self): r = mc.get(SCRETDB_MC_KEY % self.props_name) if r: return r r = self.secret_db.get(self.props_name) or {} mc.set(SCRETDB_MC_KEY % self.props_name, r) return r
def get_by_rev(self, rev): r = mc.get(SCRETDB_MC_REV_KEY % (self.props_name, rev)) if r: return r r = self.secret_db.get(self.props_name, rev=rev) mc.set(SCRETDB_MC_REV_KEY % (self.props_name, rev), r) return r
def _get_count(): try: r = mc.get(USER_COUNT_MC_KEY) if r: r = int(r) return r except: return 0
def get_ticket(): ticket = mc.get(CACHE_TICKET_KEY) if ticket: return ticket response = weixin_api.get_js_ticket() if response['errcode'] != 0: raise RuntimeError('weixin error: %r' % response) ticket = response['ticket'] expires_in = response['expires_in'] mc.set( CACHE_TICKET_KEY, ticket, ) mc.expire(CACHE_TICKET_KEY, expires_in) return ticket
def fetch_account_info(profile): """fetch all of the account order info""" yixin_account = YixinAccount.get_by_local(profile.account_id) if not yixin_account: return fetch_status = mc.get( MC_FETCH_ACCOUNT_STATUS_BY_USER.format(user_id=profile.account_id)) if fetch_status: return profile.person_account_info response = yixin.client.query.account_info(token=yixin_account.p2p_token, timeout=15) profile.person_account_info = response.data.p2pservice_list sync_orders_by_account_info(profile) # set fetch status with expire time mc.set(MC_FETCH_ACCOUNT_STATUS_BY_USER.format(user_id=profile.account_id), True) return profile.person_account_info
def close_time(self): return mc.get(self.close_time_key)
def open_time(self): return mc.get(self.open_time_key)
def is_enabled(self): return bool(mc.get(self.key))
def confirm_bind(uid, mobile): cached_mobile = mc.get(MC_BIND_MOBILE_BY_USER % uid) if mobile != cached_mobile: raise BindError(u'申请验证码与最终提交时的手机号不一致') mc.delete(MC_BIND_MOBILE_BY_USER % uid) return _confirm_bind(uid, mobile)
def get_access_token(app_id, app_secret): return mc.get(CACHE_ACCESS_TOKEN_KEY)
def get(cls, secret): return mc.get(_MC_CAPTCHA_KEY % secret)
def has_read(self, user_id): return mc.get(FUNDWEEKLY_READ_CACHE_KEY % (self.id, user_id))
def get_total_ins_children_count(): """get total user count who buy children insurance""" return mc.get(MC_TOTAL_INSURANCE_USER_COUNT) or 1
def _load_token(self): key = self._token_rds_key.format(self) data = mc.get(key) if data: return json.loads(data)
def voucher(self): return mc.get(self.key)
def images(key): v = mc.get(key) r = Response(v, mimetype='image/jpeg') return r