Shard Detail

postgres_cache_store v0.4.0

Cache::Store implementation backed by a database via crystal-pg.
crystal cache hacktoberfest postgresql postgres

Install & Use

Add the following code to your project's shard.yml under:

dependencies to use in production
- OR -
development_dependencies to use in development


postgres_cache_store:
  github: crystal-cache/postgres_cache_store

Readme

Cache::PostgresCacheStore

Crystal CI GitHub release

A cache store implementation which stores everything in the Postgres database, using crystal-pg as the backend.

Cache::PostgresCacheStore is a Crystal cache backed by a Postgres UNLOGGED table and text column.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      postgres_cache_store:
        github: crystal-cache/postgres_cache_store
    
  2. Run shards install

Usage

Before using this shard make sure you have created Postgres database. For example cache_production:

psql -c 'CREATE DATABASE cache_production;' -U postgres

A Postgres database can be opened with:

db = DB.open("postgres://postgres@localhost/cache_production")

Open and use the new cache instance:

require "postgres_cache_store"

cache = Cache::PostgresCacheStore(String, String).new(1.minute, db)

cache.write("foo", "bar")

cache.read("foo") # => "bar"

Contributing

  1. Fork it (https://github.com/crystal-cache/postgres_cache_store/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors