From 98117f047b8fbc01cc8e994b702597a13ff7a77d Mon Sep 17 00:00:00 2001 From: EVOKE Date: Tue, 2 Nov 2021 18:23:11 +0330 Subject: [PATCH] Update README.md --- README.md | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d57c16a..0d56fee 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,5 @@ # Kubo - -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/kubo`. To experiment with that code, run `bin/console` for an interactive prompt. - -TODO: Delete this and the text above, and describe your gem +Kubo is a Ruby gem to file cache easily. ## Installation @@ -21,15 +18,38 @@ Or install it yourself as: $ gem install kubo ## Usage +```ruby +# Initializing a Zip instance to compress data to GZip and the Zip class +# takes two arguments for expiration and a path for storing keys. +# Kubo::Zip.new(time, path) +# `time` argument could be "1s", "1h", "1d" which it will be converted to seconds later. +kubo = Kubo::Zip.new("1h", "./cache/my_cache_folder") + +# Save a key with value +key = "my_key" +value = "My value" +kubo.save(key, value) -TODO: Write usage instructions here +# Read a key +kubo.read(key) # => "My value" + +# Check expiration of a key +kubo.expired?(key) + +# Flush / Truncate a key +kubo.flush(key) + +# Delete a key +kubo.delete(key) +kubo.delete_if_expired(key) # Deletes the key if it's expired. +``` ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. -To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). +To install this gem onto your local machine, run `bundle exec rake install`. ## Contributing -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/kubo. +Bug reports and pull requests are welcome on GitHub at https://github.com/evokelektrique/kubo.