| 654 | } |
| 655 | |
| 656 | func (this *MemoryStorage) initPurgeTicker() { |
| 657 | var autoPurgeInterval = this.policy.MemoryAutoPurgeInterval |
| 658 | if autoPurgeInterval <= 0 { |
| 659 | autoPurgeInterval = 5 |
| 660 | } |
| 661 | |
| 662 | // 启动定时清理任务 |
| 663 | |
| 664 | if this.purgeTicker != nil { |
| 665 | this.purgeTicker.Stop() |
| 666 | } |
| 667 | |
| 668 | this.purgeTicker = utils.NewTicker(time.Duration(autoPurgeInterval) * time.Second) |
| 669 | goman.New(func() { |
| 670 | for this.purgeTicker.Next() { |
| 671 | var tr = trackers.Begin("MEMORY_CACHE_STORAGE_PURGE_LOOP") |
| 672 | this.purgeLoop() |
| 673 | tr.End() |
| 674 | } |
| 675 | }) |
| 676 | } |