got cachetest from question3, to be mofdified
added auto cache resizing