Exploring Ruby by exploring caches
- Ruby 100%
| .config/rubocop | ||
| bin | ||
| lib | ||
| spec | ||
| .rspec | ||
| Gemfile | ||
| Gemfile.lock | ||
| LICENCE.txt | ||
| mise.toml | ||
| README.md | ||
Exploring Ruby Through Caching
This project serves as an example of various classic caching algorithms in Ruby, and was written as part of an ongoing project to learn the language.
Running
The executable c will hit the selected caching algorithm with a number of
requests, with cache keys distributed according to the selected distribution:
bundle exec bin/c -n {num_requests} -d {distribution} -a {algorithm} -s
{cache_size} -f {field_size}
Cache keys can be any number within 0...field_size. The field size, along with
the number of requests and distribution affect the likelihood of a request being
hittable. The size of the cache and its algorithm affect the efficacy of the
cache in any given situation.
Available distributions:
uniform: Keys are picked from the available range completely at randomgauss:μ:σ: Keys are picked by a Gaussian (normal) distribution. Select a mean and standard deviation that make sense for your chosen field size. A mean offield_size / 2and a standard deviation of aroundfield_size / 4is a good place to start.