A cache store implementation which stores everything in the MySQL database, using crystal-mysql as the backend.
-
Add the dependency to your
shard.yml
:dependencies: mysql_cache_store: github: crystal-cache/mysql_cache_store
-
Run
shards install
Before using this shard make sure you have created MySQL database. For example cache_production
:
mysql -u root
mysql> CREATE DATABASE cache_production character set utf8mb4 collate utf8mb4_unicode_ci;
A MySQL database can be opened with:
db = DB.open("mysql://root@localhost/cache_production")
Open and use the new cache instance:
require "mysql_cache_store"
cache = Cache::MySqlCacheStore(String, String).new(1.minute, db)
cache.write("foo", "bar")
cache.read("foo") # => "bar"
Before run specs make sure you have created MySQL database `cache_test
mysql -u root
mysql> CREATE DATABASE cache_test character set utf8mb4 collate utf8mb4_unicode_ci;
crystal spec
- Fork it (https://github.com/crystal-cache/mysql_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
- Anton Maminov - creator and maintainer