gocql/gocql — pull request #187 by phillipCouto (2014-06-25 03:01:29+00:00)
Title: Added LRU Cache for Prepared statements to prevent memory leaks

This PR is related to issue #184.

A global cache for all connections is used to limit the total amount of prepared statements an instance of gocql will retain in memory. This will also improve performance for queries where they are prepared on different connections for the same host.

Slice was used as it will provide consistent performance with frequently used queries versus using a map which has a random ordering of elements.

The cache is written with thread safety in mind and can be sized up and down at run time as sessions are created with varying sizes.