R: lock and cache in GlobalDictCache