13eck
13eck
Explore posts from servers
CC#
Created by 13eck on 9/8/2023 in #help
❔ Can I serve a static file using a wildcard route?
What I want to do is map a URL to a static file. I have a character.html file that has the JS to fetch the character info from the DB but I want to have the user navigate to /character/{character_id} but still server the static file. Can I do that somehow with app.UseFileServer() or do I need to have a lone route that returns an HTML file? If so, what does that look like?
32 replies
CC#
Created by 13eck on 7/22/2023 in #help
❔ Filter a ConcurrentDictionary
I have a ConcurrentDictionary that I'm using for a small in-memory cache and I'm wondering what the best way to filter items out of it. one of the fields on the value stored in the dictionary is a DateTimeOffset expiration time and I'm still new to using it. Currently, I'm using .Select() to filter out the expired items and casting it back to the Dict, overwriting the existing variable with a new one:
_cache = (ConcurrentDictionary<string, UserCacheItem>)_cache.Select(item => item.Value.Expiry > DateTimeOffset.Now);
_cache = (ConcurrentDictionary<string, UserCacheItem>)_cache.Select(item => item.Value.Expiry > DateTimeOffset.Now);
Is there a better way to do this?
15 replies