def updatePersistentCache(self, ext, isFullSync): if ext.pop('__cache', None) is not None: if not self.__persistentCache.data: desc, cacheData = self.__persistentCache.data = self.__persistentCache.get( ) if accountDataPersistentHash(cacheData) != desc: LOG_ERROR('Local account data cache is corrupted: resync') self._resynchronize() return False self.__persistentCache.data = cacheData self.__persistentCache.isDirty = False else: cacheData = self.__persistentCache.data if cacheData is None: LOG_ERROR( "Incorrect cache state while syncing data: server said to use cache but I don't have any" ) self._resynchronize() return False accountDataMergePersistent(ext, cacheData) if synchronizeDicts(accountDataGetDiffForPersistent(ext), self.__persistentCache.data)[1]: self.__persistentCache.isDirty = True else: if self.__persistentCache.data is None: self.__persistentCache.data = {} synchronizeDicts(accountDataGetDiffForPersistent(ext), self.__persistentCache.data) self.__persistentCache.isDirty = True return True
def updatePersistentCache(self, ext, isFullSync): if ext.pop('__cache', None) is not None: if not self.__persistentCache.data: desc, cacheData = self.__persistentCache.data = self.__persistentCache.get() if accountDataPersistentHash(cacheData) != desc: LOG_ERROR('Local account data cache is corrupted: resync') self._resynchronize() return False self.__persistentCache.data = cacheData self.__persistentCache.isDirty = False else: cacheData = self.__persistentCache.data if cacheData is None: LOG_ERROR("Incorrect cache state while syncing data: server said to use cache but I don't have any") self._resynchronize() return False accountDataMergePersistent(ext, cacheData) if synchronizeDicts(accountDataGetDiffForPersistent(ext), self.__persistentCache.data)[1]: self.__persistentCache.isDirty = True else: if self.__persistentCache.data is None: self.__persistentCache.data = {} synchronizeDicts(accountDataGetDiffForPersistent(ext), self.__persistentCache.data) self.__persistentCache.isDirty = True return True
def synchronize(self, isFullSync, diff): if isFullSync: self.__cache.clear() for item in ('quests', 'tokens', 'potapovQuests'): itemDiff = diff.get(item, None) if itemDiff is not None: synchronizeDicts(itemDiff, self.__cache.setdefault(item, {}))
def synchronize(self, isFullSync, diff): if isFullSync: self.__cache.clear() goodiesFull = diff.get(('goodies', '_r'), {}) if goodiesFull: self.__cache = dict(goodiesFull) for item in ('goodies',): itemDiff = diff.get(item, None) if itemDiff is not None: synchronizeDicts(itemDiff, self.__cache.setdefault(item, {}))
def synchronize(self, isFullSync, diff): if isFullSync: self.__cache.clear() goodiesFull = diff.get(('goodies', '_r'), {}) if goodiesFull: self.__cache = dict(goodiesFull) for item in ('goodies', ): itemDiff = diff.get(item, None) if itemDiff is not None: synchronizeDicts(itemDiff, self.__cache.setdefault(item, {}))
def synchronize(self, isFullSync, diff): if isFullSync: self.__cache.clear() recycleBinFull = diff.get(('recycleBin', '_r'), {}) if recycleBinFull: self.__cache = dict(recycleBinFull) for item in ('recycleBin', ): itemDiff = diff.get(item, None) if itemDiff is not None: synchronizeDicts(itemDiff, self.__cache.setdefault(item, {})) return
def synchronize(self, isFullSync, diff): if isFullSync: self.__cache.clear() invDiff = diff.get('inventory', None) if invDiff is not None: for itemTypeIdx, itemInvDiff in invDiff.iteritems(): synchronizeDicts(itemInvDiff, self.__cache.setdefault(itemTypeIdx, {})) cacheDiff = diff.get('cache', None) if cacheDiff is not None: vehsLockDiff = cacheDiff.get('vehsLock', None) if vehsLockDiff is not None: itemInvCache = self.__cache.setdefault(_VEHICLE, {}) synchronizeDicts(vehsLockDiff, itemInvCache.setdefault('lock', {}))
def synchronize(self, isFullSync, diff): if isFullSync: self.__cache.clear() cache = self.__cache statsDiff = diff.get('stats', None) if statsDiff is not None: for stat in _SIMPLE_VALUE_STATS: if stat in statsDiff: cache[stat] = statsDiff[stat] for stat in _DICT_STATS: stat_r = (stat, '_r') if stat_r in statsDiff: cache[stat] = statsDiff[stat_r] if stat in statsDiff: synchronizeDicts(statsDiff[stat], cache.setdefault(stat, dict())) for stat in _GROWING_SET_STATS: stat_r = (stat, '_r') if stat_r in statsDiff: cache[stat] = statsDiff[stat_r] if stat in statsDiff: cache.setdefault(stat, set()).update(statsDiff[stat]) accountDiff = diff.get('account', None) if accountDiff is not None: for stat in _ACCOUNT_STATS: if stat in accountDiff: cache[stat] = accountDiff[stat] economicsDiff = diff.get('economics', None) if economicsDiff is not None: for stat in ('unlocks', 'eliteVehicles'): if stat in economicsDiff: cache.setdefault(stat, set()).update(economicsDiff[stat]) cache.setdefault(('initial', stat), set()).update(economicsDiff[stat]) cacheDiff = diff.get('cache', None) if cacheDiff is not None: for stat in _CACHE_STATS: if stat in cacheDiff: LOG_DEBUG_DEV('CACHE stat change', stat, cacheDiff[stat]) cache[stat] = cacheDiff[stat] spaDiff = cacheDiff.get('SPA', None) if spaDiff: synchronizeDicts(spaDiff, cache.setdefault('SPA', dict())) return
def synchronize(self, isFullSync, diff): if isFullSync: self.__cache.clear() cache = self.__cache statsDiff = diff.get("stats", None) if statsDiff is not None: for stat in _SIMPLE_VALUE_STATS: if stat in statsDiff: cache[stat] = statsDiff[stat] for stat in _DICT_STATS: stat_r = (stat, "_r") if stat_r in statsDiff: cache[stat] = statsDiff[stat_r] if stat in statsDiff: synchronizeDicts(statsDiff[stat], cache.setdefault(stat, dict())) for stat in _GROWING_SET_STATS: stat_r = (stat, "_r") if stat_r in statsDiff: cache[stat] = statsDiff[stat_r] if stat in statsDiff: cache.setdefault(stat, set()).update(statsDiff[stat]) accountDiff = diff.get("account", None) if accountDiff is not None: for stat in _ACCOUNT_STATS: if stat in accountDiff: cache[stat] = accountDiff[stat] economicsDiff = diff.get("economics", None) if economicsDiff is not None: for stat in ("unlocks", "eliteVehicles"): if stat in economicsDiff: cache.setdefault(stat, set()).update(economicsDiff[stat]) cacheDiff = diff.get("cache", None) if cacheDiff is not None: for stat in _CACHE_STATS: if stat in cacheDiff: LOG_DAN_DEV("CACHE stat change", stat, cacheDiff[stat]) cache[stat] = cacheDiff[stat] spaDiff = cacheDiff.get("SPA", None) if spaDiff: synchronizeDicts(spaDiff, cache.setdefault("SPA", dict())) return