TILT-caching- part 17

If you want to read about, see https://docs.microsoft.com/en-us/azure/architecture/patterns/cache-aside

So , the public TILTS must be cached. Also, when a user makes a new TILT, the cache should be destroyed

The code for Memory Cache is very simple:

  1. Add to services
builder.Services.AddMemoryCache();
  1. Add an MemoryCache cache to the constructor
public MyTilts(IMemoryCache cache, 
  1. add caching to the function
 if (cache.TryGetValue<TILT_Note_Table[]>(urlPart, out var result))
            {
                return result;
            }
            
//code to retrieve
cache.Set(urlPart, ret,DateTimeOffset.Now.AddMinutes(10));
return ret;
  1. add destroy cache
await insert.InsertTILT_Note(noteOrig);
note.CopyFrom(noteOrig);
cache.Remove(url);   
  1. Modify tests to see this feature