Skip to content

crystal-cache/mysql_cache_store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cache::MySqlCacheStore

Crystal CI GitHub release

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

Installation

  1. Add the dependency to your shard.yml:

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

Usage

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"

Development

Run specs

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

Contributing

  1. Fork it (https://github.com/crystal-cache/mysql_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