setting capacity correctly and removing enough space to make way for new cache entry
fixed compile errors