]> pilppa.com Git - lib1wire.git/commitdiff
No need to cache data calculated per minute or per secondly as the cache
authorMika Laitio <lamikr@pilppa.org>
Wed, 26 Jan 2011 00:46:56 +0000 (02:46 +0200)
committerMika Laitio <lamikr@pilppa.org>
Wed, 26 Jan 2011 00:46:56 +0000 (02:46 +0200)
size would be almost identical to original data file size.
Signed-off-by: Mika Laitio <lamikr@pilppa.org>
src/StoreCache.cc

index b444f32f90f7ed41228a24dc86fa26f1978d387b..99dec06be54e0eda35fc37c844b04ef7d776c11a 100644 (file)
@@ -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;
                }