Example #1
0
    def update_multi(self,
                     mapping,
                     isSyncNow=False):  # 如果改用redis将不允许非全字段更新,必须全表更新。
        if len(mapping) == 0:
            return
        ntime = time.time()
        data = self.get_multi(['data', '_state'])
        data['data'].update(mapping)
        if data.get('_state') == MMODE_STATE_NEW:
            props = {'data': data.get('data'), '_time': ntime}
            result = MemObject.update_multi(self, props)
            if isSyncNow:
                self.syncDB()
        else:
            props = {
                '_state': MMODE_STATE_UPDATE,
                'data': data.get('data'),
                '_time': ntime
            }
            result = MemObject.update_multi(self, props)
            if isSyncNow:
                self.syncDB()

        if not isSyncNow:
            pkval = data.get('data').get(self._pk)
            rdsclient.zadd(self.dszset, self.produceRedisKey(pkval), ntime)
        return result
Example #2
0
 def update_multi(self, mapping):
     ntime = time.time()
     data = self.get_multi(['data','_state'])
     data['data'].update(mapping)
     if data.get('_state')==1:
         props = {'data':data.get('data'),'_time':ntime}
     else:
         props = {'_state':2,'data':data.get('data'),'_time':ntime}
     return MemObject.update_multi(self, props)
Example #3
0
 def update(self, key, values):
     data = self.get_multi(['data','_state'])
     ntime = time.time()
     data[key] = values
     if data.get('_state')==1:
         props = {'data':data.get('data'),'_time':ntime}
     else:
         props = {'_state':2,'data':data.get('data'),'_time':ntime}
     return MemObject.update_multi(self,props)
Example #4
0
 def update(self, key, values):
     data = self.get_multi(['data','_state'])
     ntime = time.time()
     data['data'].update({key:values})
     if data.get('_state')==MMODE_STATE_NEW:
         props = {'data':data.get('data'),'_time':ntime}
     else:
         props = {'_state':MMODE_STATE_UPDATE,'data':data.get('data'),'_time':ntime}
     return MemObject.update_multi(self, props)
Example #5
0
 def update_multi(self, mapping):
     n_time = time.time()
     data = self.get_multi(['data', '_state'])
     data['data'].update(mapping)
     if data.get('_state') == MMODE_STATE_NEW:
         props = {'data': data.get('data'), '_time': n_time}
     else:
         props = {'_state': MMODE_STATE_UPDATE, 'data': data.get('data'), '_time': n_time}
     return MemObject.update_multi(self, props)
Example #6
0
 def update_multi(self, mapping):
     n_time = time.time()
     data = self.get_multi(['data', '_state'])
     data['data'].update(mapping)
     if data.get('_state') == MMODE_STATE_NEW:
         props = {'data': data.get('data'), '_time': n_time}
     else:
         props = {'_state': MMODE_STATE_UPDATE, 'data': data.get('data'), '_time': n_time}
     return MemObject.update_multi(self, props)
Example #7
0
 def update(self, key, values):
     data = self.get_multi(['data', '_state'])
     ntime = time.time()
     data['data'].update({key: values})
     if data.get('_state') == MMODE_STATE_NEW:
         props = {'data': data.get('data'), '_time': ntime}
     else:
         props = {'_state': MMODE_STATE_UPDATE, 'data': data.get('data'), '_time': ntime}
     return MemObject.update_multi(self, props)
Example #8
0
 def update_multi(self, mapping):
     ntime = time.time()
     data = self.get_multi(['data', '_state'])
     data['data'].update(mapping)
     if data.get('_state') == 1:
         props = {'data': data.get('data'), '_time': ntime}
     else:
         props = {'_state': 2, 'data': data.get('data'), '_time': ntime}
     return MemObject.update_multi(self, props)
Example #9
0
 def update(self, key, values):
     data = self.get_multi(['data', '_state'])
     ntime = time.time()
     data[key] = values
     if data.get('_state') == 1:
         props = {'data': data.get('data'), '_time': ntime}
     else:
         props = {'_state': 2, 'data': data.get('data'), '_time': ntime}
     return MemObject.update_multi(self, props)
Example #10
0
    def update(self, key, values):
        data = self.get_multi(['data', '_state'])
        ntime = time.time()
        data['data'].update({key: values})
        if data.get('_state') == MMODE_STATE_NEW:
            props = {'data': data.get('data'), '_time': ntime}
        else:
            props = {'_state': MMODE_STATE_UPDATE, 'data': data.get('data'), '_time': ntime}

        pkval = data.get('data').get(self._pk)
        rdsclient.zadd(self.dszset, self.produceRedisKey(pkval), ntime)
        return MemObject.update_multi(self, props)
Example #11
0
 def update_mem_only(self, mapping):
     """更新缓存数据不同步数据库"""
     if len(mapping) == 0:
         return
     ntime = time.time()
     data = self.get_multi(['data'])
     data['data'].update(mapping)
     props = {
         'data': data.get('data'),
         '_time': ntime
     }  # 不同步sql,所以不写入redis,不修改状态
     result = MemObject.update_multi(self, props)
     return result