ASP.NET caching issue

I have two items in the cache

  • Key: Cat
  • Key: Animal_Vacinations

Now Animal_Vacinationshas a key-based cache dependency on Cat. So, if something changes for the cache element Cat, then the cache element Animal_Vacinationswill become invalid. PERFECT :)

Ok .. now to the problem.

After creating the second cache element (i.e. Animal_Vacinations), I add a third cache object: -

  1. Key: Dog

The problem is that the second object must also be dependent on Dog. During the creation of the second object, he knows what elements he should depend on. So, in this example, the Animal_Vacination object knows that it should depend on ...

  • Cat
  • Dog
  • Bird
  • John Skeet

, Animal_Vacination 4 , . , . (.. Cache["Animal_Vacination"] == null).

, 4 ... 1 _exist_... .

.

, , 2- .

... - , 1 , ?

+3
2

, , , , , .

, - - "Animal_Vacinations" , , "Animal_Vacinations" , -, , , , .

, , , , "Cat", "Animal_Vacinations" , , "Animal_Vacinations" , , "", "", "", " "; , - (, ) ( "", "" " " ); , "Animal_Vacinations" . ( , Cache.Add - , Get, , , .)

, - "", "" "", , ( ), "", Null, "Animal_Vacinations" .

+1

, , . :
Cat
Animal_Vacinations
cache dependecy Animal_Vacinations

cache dependecy Animal_Vacinations, .
Bird
cache dependecy Animal_Vacinations, Bird,
...

0

Source: https://habr.com/ru/post/1708321/


All Articles