示例#1
0
 def memorise(self, ts):
     '''
     Save timeserie into cacje and save itself
     '''
     if ts:
         st = todate(ts.front()[0])
         ed = todate(ts.back()[0])
         self.start[ts.name] = st
         self.end[ts.name] = ed
         tslist = [(todate(d), v) for d, v in ts.items()]
         self.backend.set(ts.name, tslist, settings.RATE_CACHE_SECONDS)
         self.save()
         self.logger.debug('Cached %s from %s to %s' % (ts.name, st, ed))
     else:
         self.start = None
         self.end = None
示例#2
0
文件: cache.py 项目: OspreyX/flow
 def memorise(self, ts):
     '''
     Save timeserie into cacje and save itself
     '''
     if ts:
         st = todate(ts.front()[0])
         ed = todate(ts.back()[0])
         self.start[ts.name] = st
         self.end[ts.name]   = ed
         tslist              = [(todate(d),v) for d,v in ts.items()]
         self.backend.set(ts.name,tslist,settings.RATE_CACHE_SECONDS)
         self.save()
         self.logger.debug('Cached %s from %s to %s' % (ts.name,st,ed))
     else:
         self.start = None
         self.end   = None
示例#3
0
    def timeseries(self, vfid):
        '''        
        @param vfid: vendor field id
        @see: jflow.core.rates.factory.factory.vendorfieldid 
        '''
        key = self.tsname(vfid)
        nts = self._timeseries.get(key, None)

        if nts == None:
            fts = self.backend.get(key, [])
            if vfid.numeric:
                nts = numericts(key)
            else:
                nts = dateseries(key)

            for d, v in fts:
                nts[todate(d)] = v

            self._timeseries[key] = nts

        return nts
示例#4
0
文件: cache.py 项目: OspreyX/flow
 def timeseries(self, vfid):
     '''        
     @param vfid: vendor field id
     @see: jflow.core.rates.factory.factory.vendorfieldid 
     '''
     key    = self.tsname(vfid)
     nts    = self._timeseries.get(key,None)
          
     if nts == None:
         fts  = self.backend.get(key,[])
         if vfid.numeric:
             nts = numericts(key)
         else:
             nts = dateseries(key)
         
         for d,v in fts:
             nts[todate(d)] = v
         
         self._timeseries[key] = nts
                         
     return nts