memory_cache
Version, currently 0.4.14 versions
- 0.4.1latestMar 27, 2021
- 0.4not indexedMar 28, 2021
- 0.3not indexedMar 28, 2021
- 0.2not indexedMar 28, 2021
github.com/kostya/memory_cache
Super simple in memory key-value storage with expires for Crystal.
30 stars
3 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
memory_cache:
github: kostya/memory_cache
version: ~> 0.4.1Then run:
shards installshard.yml
- Crystal
>= 0.35.1, < 2.0.0- License
- MIT
- Author
- Konstantin Makarchev
Dependencies
This version declares no dependencies.
README
MemoryCache
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
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.4.1- Tagged
- Mar 27, 2021
- Commit
599b46ca14d3- Crystal
>= 0.35.1, < 2.0.0- Indexed
- yes
Dependents
Repository
github.com/kostya/memory_cache
Metadata
- Created
- Aug 12, 2026
- Updated
- Oct 24, 2026
- Synced
- Oct 24, 2026
- Versions
- 4