]> pilppa.org Git - lib1wire.git/blobdiff - src/StoreCache.cc
No need to cache data calculated per minute or per secondly as the cache
[lib1wire.git] / 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;
                }