postgres_cache_store v0.4.0
Cache::PostgresCacheStore
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
-
Add the dependency to your
shard.yml
:dependencies: postgres_cache_store: github: crystal-cache/postgres_cache_store
-
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
- Fork it (https://github.com/crystal-cache/postgres_cache_store/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Anton Maminov - creator and maintainer
Repository
postgres_cache_store
Owner
Statistic
- 5
- 0
- 0
- 0
- 3
- over 2 years ago
- January 5, 2021
License
MIT License
Links
Synced at
Sun, 22 Dec 2024 01:04:46 GMT
Languages