Add caching to `toArray` method

Reflection can be slow on occasions and this optimization should be beneficial if `toArray` is being called more than once per request.
Minor changes to caching

- Cache constants rather than reflection objects
- Make static cache private
Typo
Merge pull request #2 from garoevans/patch-1

Add caching to `toArray` method