{"repo":"prashanthpai/sqlcache","free":true,"listed":false,"github":"https://github.com/prashanthpai/sqlcache","clone":"git clone https://github.com/prashanthpai/sqlcache.git","description":"Caching middleware for database/sql","language":"Go","stars":53,"topics":["cache","sql","database","golang","go","pgx","sqlmw","redis","ristretto","middleware"],"license":"MIT","category":"databases-storage","readme_excerpt":"sqlcache sqlcache is a caching middleware for database/sql that enables existing Go programs to add caching in a declarative way. It leverages APIs provided by the handy sqlmw project and is inspired from slonik-interceptor-query-cache. This liberates your Go program from maintaining imperative code that repeatedly implements the cache-aside pattern. Your program will perceive the database client/driver as a read-through cache. Tested with PostgreSQL database with pgx as the underlying driver. Cache backends supported: ristretto (in-memory) redis It's easy to add other caching backends by implementing the cache.Cacher interface. Usage Create a backend cache instance and install the interceptor: Caching is controlled using cache attributes which are SQL comments starting with @cache- prefix. Only queries with cache attributes are cached. Cache attributes: Cache attribute Description Required? Default --- --- --- --- @cache-ttl Number (in seconds) to cache the query for. Yes N/A @cache-max-rows Don't cache if number of rows in query response exceeds this limit. Yes N/A Example query: See example/main.go for a full working example. References A declarative way to cache PostgreSQL queries using Node.js: a blog post by the author of Slonik. Declarative Caching with Postgres and Redis: Kyle Davis's talk on Slonik + Redis.","default_branch":null,"files":null,"tree":[],"storefront":"/r/prashanthpai","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/prashanthpai/sqlcache/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}