expiring_hash
Inspired by expiringdict
Installation
-
Add the dependency to your
shard.yml
:dependencies: expiring_hash: github: lun-4/expiring_hash
-
Run
shards install
Usage
require "expiring_hash"
alias MyCoolCache = ExpiringHash(String, String)
# hash entries can be kept inside the expiring hash for more than 5 minutes,
# trying to access those entires will mean their deletion, though.
#
# if the hash has more than 10 times, all entries that should be deleted will be.
# the insert operation will fail if no entries are invalidated
#
# set max_items to `nil` to remove this behavior
my_cool_cache = MyCoolCache.new(10, 5.minutes)
# use as any hash
my_cool_cache["a"] = "b"
Contributing
- Fork it (https://github.com/lun-4/expiring_hash/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
Contributors
- lun-4 - creator and maintainer