@@ -68,6 +68,7 @@ Package cachego provides an easy way to use foundation for your caching operatio
6868 // Use NewCacheWithReport to create a cache with report.
6969 cache, reporter := cachego.NewCacheWithReport(cachego.WithCacheName("test"))
7070 fmt.Println(reporter.CacheName())
71+ fmt.Println(reporter.CacheType())
7172
72732. ttl:
7374
@@ -351,16 +352,21 @@ Package cachego provides an easy way to use foundation for your caching operatio
351352 fmt.Printf("report: load key %s value %+v ttl %s, err %+v, load count %d\n", key, value, ttl, err, reporter.CountLoad())
352353 }
353354
354- // We provide some reporting points for monitor cache.
355- // ReportMissed reports the missed key getting from cache.
356- // ReportHit reports the hit entry getting from cache.
357- // ReportGC reports the status of cache gc.
358- // ReportLoad reports the result of loading.
359- // Use NewCacheWithReport to create a cache with report.
355+ // We provide some ways to report the status of cache.
356+ // Use NewCacheWithReport to create a cache with reporting features.
360357 cache, reporter := cachego.NewCacheWithReport(
358+ // Sometimes you may have several caches in one service.
359+ // You can set each name by WithCacheName and get the name from reporter.
360+ cachego.WithCacheName("test"),
361+
362+ // For testing...
361363 cachego.WithMaxEntries(3),
362364 cachego.WithGC(100*time.Millisecond),
363365
366+ // ReportMissed reports the missed key getting from cache.
367+ // ReportHit reports the hit entry getting from cache.
368+ // ReportGC reports the status of cache gc.
369+ // ReportLoad reports the result of loading.
364370 cachego.WithReportMissed(reportMissed),
365371 cachego.WithReportHit(reportHit),
366372 cachego.WithReportGC(reportGC),
@@ -387,7 +393,9 @@ Package cachego provides an easy way to use foundation for your caching operatio
387393
388394 fmt.Println(value, err)
389395
390- // These are some methods of reporter.
396+ // These are some useful methods of reporter.
397+ fmt.Println("CacheName:", reporter.CacheName())
398+ fmt.Println("CacheType:", reporter.CacheType())
391399 fmt.Println("CountMissed:", reporter.CountMissed())
392400 fmt.Println("CountHit:", reporter.CountHit())
393401 fmt.Println("CountGC:", reporter.CountGC())
@@ -396,11 +404,6 @@ Package cachego provides an easy way to use foundation for your caching operatio
396404 fmt.Println("MissedRate:", reporter.MissedRate())
397405 fmt.Println("HitRate:", reporter.HitRate())
398406
399- // Sometimes you may have several caches in one service.
400- // You can set each name by WithCacheName and get the name from reporter.
401- cachego.WithCacheName("test")
402- reporter.CacheName()
403-
4044079. task:
405408
406409 var (
@@ -477,4 +480,4 @@ Package cachego provides an easy way to use foundation for your caching operatio
477480package cachego // import "github.com/FishGoddess/cachego"
478481
479482// Version is the version string representation of cachego.
480- const Version = "v0.4.9 "
483+ const Version = "v0.4.10 "
0 commit comments