counter_tree
CounterTree
A sectioned hash table for storing counters that allow you to store values on a specific date and fetch as a sum or slice between two dates. This is part of the Karma
Installation
-
Add the dependency to your
shard.yml
:dependencies: counter_tree: github: creadone/counter_tree
-
Run
shards install
Usage
require "counter_tree"
# Init with 9 sections
tree = CounterTree::Tree.new(9)
# Increment value for key
tree.increment(1234_u64)
# Decrement value for key
tree.decrement(1234_u64)
# Fetch sum of values for key
tree.sum(1234_u64)
# Fetch sum between timestamps for key
tree.sum(1234_u64, 1684767251993, 1684767253996)
# Fetch hash between timestamps for key
tree.find(1234_u64, 1684767251993, 1684767253996)
# Fetch hash between timestamps for all counters
tree.find(1684767251993, 1684767253996)
# Delete values between timestamps for key
tree.delete(1234_u64, 1684767251993, 1684767253996)
# Delete values between timestamps over all counters
tree.delete(1684767251993, 1684767253996)
# Reset counter for key
tree.reset(1234_u64)
# Reset all counters
tree.reset
# Store tree to msgpack
CounterTree.dump(tree)
# Load tree from msgpack
CounterTree.load(tree_bytes)
Contributing
- Fork it (https://github.com/your-github-user/counter_tree/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
- creadone - creator and maintainer
Repository
counter_tree
Owner
Statistic
- 0
- 0
- 0
- 1
- 1
- over 1 year ago
- July 5, 2023
License
MIT License
Links
Synced at
Sun, 24 Nov 2024 23:29:44 GMT
Languages