why are you caching the ps output and not the pid if i were writing this  i would probably factor out two inner methods here get pid of cached and  get pid of get pid of would do the work to actually find the pid  and  get pid of cached would just handle the caching logic 