Closed
Description
There are some use cases where we know we have enough memory
and we want to be as fast as possible so we just want to hold
in memory a ResultSet related to a given Statement.
This commit implements a new type of cache using memory
instead of hard disk files.
It uses a naive implementation with ByteArrayStreams which is not recommended for production.
// Initialize the cache driver
Class.forName("com.qwazr.jdbc.cache.Driver");
// Provide the URL and the Class name of the backend driver
Properties info = new Properties();
info.setProperty("cache.driver.url", "jdbc:derby:memory:myDB;create=true");
info.setProperty("cache.driver.class", "org.apache.derby.jdbc.EmbeddedDriver");
// Get your JDBC connection
Connection cnx = DriverManager.getConnection("jdbc:cache:mem:my-memory-cache", info);
The syntax of the URL can be:
- jdbc:cache:file:{path-to-the-cache-directory} for on disk cache
- jdbc:cache:mem:{name-of-the-cache} for in memory cache