couchbaselabs / Couchbase.Extensions

Extensions for Couchbase for .Net Core
Apache License 2.0
27 stars 14 forks source link

Potential Bug When Using Distributed Cache Options With AbsoluteExpiration Properties #45

Closed mmmasent closed 6 years ago

mmmasent commented 6 years ago

Summary

When trying to use IDistributedCache, associated with Couchbase.Extensions.Caching, there seems to be a possible issue when using the AbsoluteExpiration or AbsoluteExpirationRelativeToNow options that are used by DistributedCacheEntryOptions. If either AbsoluteExpiration property is set, while using an ephemeral couchbase bucket, the document is cached but is seemingly deleted instantly from the bucket.

Environment Used

The local couchbase instance is deployed via docker and uses enterprise-5.1.0

Steps To Reproduce

  1. Use Couchbase.Extensions.Caching in a .NET project and add AddDistributedCouchbaseCache to the startup configuration
  2. Using Dependency Injection, retrieve an IDistributedCache in a repository class
  3. Call the SetAsync method and pass in a option parameter with the Absolute property set; Example: await _cache.SetAsync(docKey, serviceResult.Value, new DistributedCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(15)});
  4. Attempt to retrieve document using GetAsync returns null and inspection of the ephemeral cache bucket shows no document exists

Side Note

SetAsync seems to successfully cache and retrieve a document when neither of the AbsoluteExpiration properties are set

jeffrymorris commented 6 years ago

Thanks for the patch @mmmasent