Selaa lähdekoodia

wip:图形验证码缓存时间

wangshan 5 kuukautta sitten
vanhempi
commit
81c668b6c7
2 muutettua tiedostoa jossa 2 lisäystä ja 2 poistoa
  1. 1 1
      gocaptcha/start.go
  2. 1 1
      gocaptcha/store.go

+ 1 - 1
gocaptcha/start.go

@@ -17,7 +17,7 @@ const (
 	dy         = 80
 	fontSize   = 75
 	Rn         = 1
-	CollectNum = 100
+	CollectNum = 50
 	Expiration = 10 * time.Minute
 )
 

+ 1 - 1
gocaptcha/store.go

@@ -96,10 +96,10 @@ func (s *memoryStore) Get(id string, clear bool) (digits []byte) {
 }
 
 func (s *memoryStore) collect() {
-	now := time.Now()
 	s.Lock()
 	defer s.Unlock()
 	s.numStored = 0
+	now := time.Now()
 	for e := s.idByTime.Front(); e != nil; {
 		ev, ok := e.Value.(idByTimeValue)
 		if !ok {