local_cache_test.go 466 B

123456789101112131415161718192021222324
  1. package localcache
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "time"
  7. )
  8. func TestNewLocalCache(t *testing.T) {
  9. Register("test", func(context context.Context, cache Cache) {
  10. fmt.Println(time.Now().Format("2006-01-02 15:04:05"))
  11. for index, _ := range [100]int{} {
  12. cache.Put(uint64(index), fmt.Sprintf("cache-%d", index))
  13. }
  14. panic("1111")
  15. })
  16. Start()
  17. tick := time.NewTicker(time.Millisecond * 500)
  18. for {
  19. <-tick.C
  20. fmt.Println(Get("test", uint64(1)))
  21. }
  22. }