John McCaskey wrote:
Throwing an exception when there is no such key seems a bit scary to me.
I used to think that exceptions are throwed in case of some errors, but
missing key doesn't look as error to me.
I agree with that, it was just a quick thought. But you are very right,
it would probably be a bit of an abuse of exceptions.
Also, keep in mind, depending on the lang of course, throwing exceptions
is not generally a fast thing to do. Exceptions should be used (IMO)
for "exceptional" situations, where something does not behave as it
should. A cache key miss is an entirely valid outcome from a cache
request. Not an exception in my mind.
Does PHP not have nulls?
greg