mysql_cache_store v0.2.0

Cache::Store implementation backed by a MySQL database

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

Repository

mysql_cache_store

Owner
Statistic
  • 2
  • 0
  • 0
  • 0
  • 3
  • over 1 year ago
  • October 27, 2021
License

MIT License

Links
Synced at

Tue, 07 May 2024 08:25:53 GMT

Languages