From: Mika Laitio Date: Wed, 26 Jan 2011 00:46:56 +0000 (+0200) Subject: No need to cache data calculated per minute or per secondly as the cache X-Git-Url: http://pilppa.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=36db98966cfc73303c75879811cdedb472d71a4a;p=lib1wire.git No need to cache data calculated per minute or per secondly as the cache size would be almost identical to original data file size. Signed-off-by: Mika Laitio --- diff --git a/src/StoreCache.cc b/src/StoreCache.cc index b444f32..99dec06 100644 --- a/src/StoreCache.cc +++ b/src/StoreCache.cc @@ -186,7 +186,11 @@ DataRange *StoreCache::get_mean(EnumSummaryPeriod period_type_param) { store = new StoreDay(device_id, date); ret_val = store->get_mean(period_type_param); - save(fname, ret_val, 4); + if ((period_type_param != PERIOD_MINUTELY) || + (period_type_param != PERIOD_SECONDLY)) { + // no need cache second or minute data + save(fname, ret_val, 4); + } delete(store); } break; @@ -295,7 +299,11 @@ DataRange *StoreCache::get_sum(EnumSummaryPeriod period_type_param) { case PERIOD_SECONDLY: store = new StoreDay(device_id, date); ret_val = store->get_sum(period_type_param); - save(fname, ret_val, 4); + if ((period_type_param != PERIOD_MINUTELY) || + (period_type_param != PERIOD_SECONDLY)) { + // no need cache second or minute data + save(fname, ret_val, 4); + } delete(store); break; } @@ -418,7 +426,11 @@ DataRange *StoreCache::get_delta(EnumSummaryPeriod period_type_param) { case PERIOD_SECONDLY: store = new StoreDay(device_id, date); ret_val = store->get_delta(period_type_param); - save(fname, ret_val, 4); + if ((period_type_param != PERIOD_MINUTELY) || + (period_type_param != PERIOD_SECONDLY)) { + // no need cache second or minute data + save(fname, ret_val, 4); + } delete(store); break; } @@ -536,7 +548,11 @@ DataRange *StoreCache::get_max(EnumSummaryPeriod period_type_param) { case PERIOD_SECONDLY: store = new StoreDay(device_id, date); ret_val = store->get_max(period_type_param); - save(fname, ret_val, 4); + if ((period_type_param != PERIOD_MINUTELY) || + (period_type_param != PERIOD_SECONDLY)) { + // no need cache second or minute data + save(fname, ret_val, 4); + } delete(store); break; } @@ -654,7 +670,11 @@ DataRange *StoreCache::get_min(EnumSummaryPeriod period_type_param) { case PERIOD_SECONDLY: store = new StoreDay(device_id, date); ret_val = store->get_min(period_type_param); - save(fname, ret_val, 4); + if ((period_type_param != PERIOD_MINUTELY) || + (period_type_param != PERIOD_SECONDLY)) { + // no need cache second or minute data + save(fname, ret_val, 4); + } delete(store); break; }