It seems like this cache check is in the wrong place: you do the query above, and then check the cache, and if it has an entry, you throw away the results of the query.  Shouldn't you avoid the query if there's something in the cache?