I have problems with cache. When I use regex like its written it deas not remove anything from cache bacause regex.IsMatch always return false.
For example I send pattern "Nop.productoptionvalue.allbyproductidoptionid-{0}-{1}-{2}" and value of key is "Nop.productoptionvalue.allbyproductidoptionid-95-2-8". That gives me false.
I'm not good et regular expressions but isn't {0} for 0 symbols {1} for 1 symbol,...
Basicly only _cache.Clear() works because it does not compare anything.
For now I will chage this and use ... StartsWith and cut of averything from first "{" to the end for comparation.
Your understanding of the {n} characters is correct. This is a bug, but only for those cache keys with more than two parameters.
{n} means match the proceding element n times, so of course {0} (no match) and {1} (1 match) will work.
The best bet is to pass in just the start of the key e.g. "Nop.productoptionvalue.allbyproductidoption.id". Really there isn't any need to use RegularExpressions for checking against the cached items, you could just have:
I already did this without regex but little bit different. I did not choose "-" but "{" as first char to look for. This will I assume be good for every pattern because all variables are at the end.