[2637] Added caching and locking function and test

https://gist.github.com/dpolcyn/13bbecbad3e91640ba0f#file-gistfile1-txt