Package list golang-github-renekroon-ttlcache / 861d7c0
New upstream version 2.8.1+ds Sascha Steinbiss 9 months ago
2 changed file(s) with 14 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
311311 if exists {
312312 cache.metrics.Retrievals++
313313 dataToReturn = item.data
314 ttlToReturn = time.Until(item.expireAt)
314 if !cache.skipTTLExtension {
315 ttlToReturn = item.ttl
316 } else {
317 ttlToReturn = time.Until(item.expireAt)
318 }
315319 if ttlToReturn < 0 {
316320 ttlToReturn = 0
317321 }
853853 assert.NotNil(t, data, "Expected data to be not nil")
854854 assert.Equal(t, nil, exists, "Expected data to exist")
855855 assert.Equal(t, "world", (data.(string)), "Expected data content to be 'world'")
856 assert.Equal(t, ttl, orgttl, "Expected item TTL to be original TTL")
857
858 cache.SkipTTLExtensionOnHit(true)
859 cache.SetWithTTL("hello", "world", orgttl)
860 time.Sleep(10 * time.Millisecond)
861 data, ttl, exists = cache.GetWithTTL("hello")
862 assert.NotNil(t, data, "Expected data to be not nil")
863 assert.Equal(t, nil, exists, "Expected data to exist")
864 assert.Equal(t, "world", (data.(string)), "Expected data content to be 'world'")
856865 assert.Less(t, ttl, orgttl, "Expected item TTL to be less than the original TTL")
857866 assert.NotEqual(t, int(ttl), 0, "Expected item TTL to be not 0")
858867 }