Bug#1115451

When a picture is deleted the get_all_pictures key is removed from the cache but any event associated with the picture has the key as get_all_pictures+event.id in the cache. That's why the reference still persists. To rectify that, before rendering the page just check whether  the result from trying to get 'get_all_pictures' is the same as the result from the 'get_all_pictures+event.id' case. If it is, wonderful else something happened (this could be that the picture was deleted or a new picture was added or both happened, one after the other. In this case always go to the db and reset the cache values).

The test is only for the case mentioned in the bug.