couchbaselabs / Couchbase.Extensions

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

Handle doc not found in typed caching extensions #98

Closed brantburnett closed 2 years ago

brantburnett commented 2 years ago

Motivation

Previous changes to handle DocumentNotFoundException when getting from the cache missed the static extension methods.

Modifications

Handle the DocumentNotFoundException in the static extension methods, returning default/null on a cache miss.

Add nullable annotations indicating the potential null return value, which required moving up to C# 9.

Results

Strongly-typed gets from the cache now return null instead of throwing an exception, correctly matching the interface spec for IDistributedCache.