| 1241 | } |
| 1242 | |
| 1243 | func StoreSync(db DB, closer *z.Closer) { |
| 1244 | defer closer.Done() |
| 1245 | // We technically don't need to call this due to mmap being able to survive process crashes. |
| 1246 | // But, once a minute is infrequent enough that we won't lose any performance due to this. |
| 1247 | ticker := time.Tick(time.Minute) |
| 1248 | |
| 1249 | for { |
| 1250 | select { |
| 1251 | case <-ticker: |
| 1252 | if err := db.Sync(); err != nil { |
| 1253 | glog.Errorf("Error while calling db sync: %+v", err) |
| 1254 | } |
| 1255 | case <-closer.HasBeenClosed(): |
| 1256 | return |
| 1257 | } |
| 1258 | } |
| 1259 | } |
| 1260 | |
| 1261 | // DeepCopyJsonMap returns a deep copy of the input map `m`. |
| 1262 | // `m` is supposed to be a map similar to the ones produced as a result of json unmarshalling. i.e., |