From 36db98966cfc73303c75879811cdedb472d71a4a Mon Sep 17 00:00:00 2001 From: Mika Laitio Date: Wed, 26 Jan 2011 02:46:56 +0200 Subject: [PATCH] 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 --- src/StoreCache.cc | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) 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; } -- 2.41.0