2

I'm using System.Runtime.Caching to cache an object that I grab from DB based on parameters that were passed to me. The problem is that the parameters could be

"1234"

or

"1234,2345,3456,4567,5678,............................6543"

My best guess is that the length of the whole key could go up to 300 characters and maybe even a little longer then that.

Am I safe with System.Runtime.Caching? Is there a limit on the key size?

halfer
  • 19,824
  • 17
  • 99
  • 186
Dimskiy
  • 5,233
  • 13
  • 47
  • 66
  • How did you come up with a value of 300 ? I don't think there is an explicit limit, but if there is, it's probably high enough that you don't need to worry about it. Anyway, if the keys are long enough for the limit to be a problem, you should probably reconsider your design... – Thomas Levesque Nov 03 '11 at 21:17
  • Just by somewhat knowing the business rules, each value is 5 characters long and it's a comma separated string. I know I've heard about 50 of these before, so 50*6=300. As for design reconsideration, that's what I'm trying to figure out atm ;p – Dimskiy Nov 03 '11 at 21:28
  • 1
    See http://stackoverflow.com/questions/2330621/maximum-length-of-cache-keys-in-httpruntime-cache-object – goodeye Jan 15 '13 at 02:34

1 Answers1

1

My guess is that's as the key is a string and just the reference to that string is stored (in the cache object) as key, there is no practical limit to the length of that key-string.

Hans Kesting
  • 38,117
  • 9
  • 79
  • 111