u 3 years ago
parent
commit
83f0683ebd
  1. 12
      core.go

12
core.go

@ -1,12 +1,10 @@
package time_arrow package time_arrow
import ( import (
"encoding/json"
"fmt" "fmt"
"log" "log"
"sort" "sort"
"strings" "strings"
"sync"
"time" "time"
"github.com/google/uuid" "github.com/google/uuid"
@ -119,7 +117,7 @@ func isInDayOfMonth(t time.Time, ta TimeArrow) bool {
return false return false
} }
var isInTimeOfDayCacheBool sync.Map
// var isInTimeOfDayCacheBool sync.Map
func isInTimeOfDay(t time.Time, ta TimeArrow) bool { func isInTimeOfDay(t time.Time, ta TimeArrow) bool {
@ -130,8 +128,8 @@ func isInTimeOfDay(t time.Time, ta TimeArrow) bool {
tfdate := t.Format("2006-01-02 15:04:05") tfdate := t.Format("2006-01-02 15:04:05")
var err error var err error
tmp, err := json.Marshal(ta.TimesOnDay)
mainKey := fmt.Sprintf("[%s][%s]", tfdate, string(tmp))
// tmp, err := json.Marshal(ta.TimesOnDay)
// mainKey := fmt.Sprintf("[%s][%s]", tfdate, string(tmp))
// value, ok := isInTimeOfDayCacheBool.Load(mainKey) // value, ok := isInTimeOfDayCacheBool.Load(mainKey)
// if ok && err == nil { // if ok && err == nil {
@ -199,11 +197,11 @@ func isInTimeOfDay(t time.Time, ta TimeArrow) bool {
} }
if (t.After(startTime) || t.Equal(startTime)) && t.Before(endTime) { if (t.After(startTime) || t.Equal(startTime)) && t.Before(endTime) {
isInTimeOfDayCacheBool.Store(mainKey, 3)
// isInTimeOfDayCacheBool.Store(mainKey, 3)
return true return true
} }
} }
isInTimeOfDayCacheBool.Store(mainKey, 4)
// isInTimeOfDayCacheBool.Store(mainKey, 4)
return false return false
} }

Loading…
Cancel
Save