expiring_hash

expiring hash for crystal

expiring_hash

Inspired by expiringdict

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      expiring_hash:
        github: lun-4/expiring_hash
    
  2. 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

  1. Fork it (https://github.com/lun-4/expiring_hash/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

  • lun-4 - creator and maintainer
Repository

expiring_hash

Owner
Statistic
  • 3
  • 0
  • 0
  • 2
  • 0
  • over 3 years ago
  • January 6, 2021
License

MIT License

Links
Synced at

Fri, 22 Nov 2024 08:11:33 GMT

Languages