Skip to content

Commit

Permalink
删除不相关代码
Browse files Browse the repository at this point in the history
  • Loading branch information
Camelsky committed Aug 14, 2014
1 parent 67ba9fd commit e14a1d3
Showing 1 changed file with 18 additions and 36 deletions.
54 changes: 18 additions & 36 deletions dwarf/dau.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python
#-*- coding:utf-8 -*-
# get dau

import sys, os
import sys
import os
import redis
import time
import logging
Expand Down Expand Up @@ -100,23 +100,11 @@ def __init__(self, baseday=None, redis_cli=None,
def _get_cache(self, key):
logging.debug('get from cache: %s', key)
return self.cache.get_cache(key)
if self._cache_dict.has_key(key):
cache = self._cache_dict.get(key)
logging.debug('Get cache: %s %s', key, cache.count)
return cache

def _cache(self, key, value):
if self._is_cache:
return self.cache._set_cache(key, value)
self._cache_reduce()
self._cache_dict.update({key:value})
logging.debug('save cache: %s %s', key, value.count())

def _cache_reduce(self):
return
while len(self._cache_dict) > self._max_cache_lens:
if len(self._cache_dict) > 0:
self._cache_dict.popitem()


def _list_day(self, fday=None, tday=None):
Expand All @@ -142,29 +130,23 @@ def _make_bitmap(self, day=None, Type='dau'):
dauKey = DAU_KEY.format(month=day.strftime(self.config.MONTH_FORMAT))
else:
dauKey = DAU_KEY.format(date=day.strftime(self.config.DATE_FORMAT))
# cache_data = self._get_cache(dauKey)
# dauBitmap = self._get_cache(dauKey) or dauBitmap
# if cache_data is None or True:
if True:
dauBitmap = Bitmap()
cached = self._get_cache(dauKey)
if cached:
bitsDau = cached
if cached is 'None':
bitsDau = None
else:
logging.debug('no cache:%s',dauKey)
bitsDau = self.REDIS.get(dauKey)
self._cache(dauKey, bitsDau or 'None')
if bitsDau:
dauBitmap.frombytes(bitsDau)
# logging.debug('Init bitmap:Count: %s' % (dauBitmap.count()))
if self.filters:
dauBitmap.filter(self.filters)
# logging.info('Filter bitmap: f-%s b-%s' % (self.filters.count(), dauBitmap.count()))
# self._cache(dauKey, dauBitmap)
dauBitmap = Bitmap()
cached = self._get_cache(dauKey)
if cached:
bitsDau = cached
if cached is 'None':
bitsDau = None
else:
dauBitmap = cache_data
logging.debug('no cache:%s',dauKey)
bitsDau = self.REDIS.get(dauKey)
self._cache(dauKey, bitsDau or 'None')
if bitsDau:
dauBitmap.frombytes(bitsDau)
# logging.debug('Init bitmap:Count: %s' % (dauBitmap.count()))
if self.filters:
dauBitmap.filter(self.filters)
# logging.info('Filter bitmap: f-%s b-%s' % (self.filters.count(), dauBitmap.count()))
# self._cache(dauKey, dauBitmap)
logging.debug('_make_bitmap Handler:%s %s - %s Sec' % (day,Type,time.time()-s))
return dauBitmap

Expand Down

0 comments on commit e14a1d3

Please sign in to comment.