GitXplorerGitXplorer
k

memory_cache

public
29 stars
0 forks
0 issues

Commits

List of commits on branch master.
Verified
599b46ca14d35d22e3fb6d44b58b053d8e4c91a7

Merge pull request #7 from dbohdan/master

kkostya committed 4 years ago
Unverified
a032065dec5c07cde50dfd2bb9b65a202fbc1bd8

Update for Crystal 1.0.0; bump version to 0.4.1

ddbohdan committed 4 years ago
Unverified
5a3339a2edfabb35be057c192a57ee05f11809b7

0.4

kkostya committed 4 years ago
Unverified
58fbe6f9dd7a83315b224d74e9813f619f25ab32

cleanup also rehash

kkostya committed 4 years ago
Unverified
94e400f959830d09cd0f3c66d7fb8729df43add5

exists, check that key not expired

kkostya committed 4 years ago
Verified
c42bb09ee3ac013091110bb3f334926d8ea5e8d1

Merge pull request #6 from j8r/improve-fetch-method

kkostya committed 4 years ago

README

The README file for this repository.

MemoryCache

CI

Super simple in memory key-value storage with expires for Crystal.

Installation

Add this to your application's shard.yml:

dependencies:
  memory_cache:
    github: kostya/memory_cache

Usage

require "memory_cache"

cache = MemoryCache(String, Int32).new

cache.write("bla", 1)
p cache.read("bla") # => 1

cache.fetch("haha") { 2 }
p cache.read("haha") # => 2

cache.write("expired1", 1, expires_in: 1.second)
p cache.read("expired1") # => 1
sleep 1
p cache.read("expired1") # => nil

p cache.fetch("expired1", expires_in: 1.second) { 2 } # => 2
p cache.fetch("expired1", expires_in: 1.second) { 3 } # => 2
sleep 1
p cache.fetch("expired1", expires_in: 1.second) { 3 } # => 3