https://github.com/evokelektrique/kubo
File cache in Ruby
https://github.com/evokelektrique/kubo
file-cache ruby ruby-gem
Last synced: 7 months ago
JSON representation
File cache in Ruby
- Host: GitHub
- URL: https://github.com/evokelektrique/kubo
- Owner: evokelektrique
- Created: 2021-10-30T22:25:41.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-11-02T15:23:45.000Z (over 4 years ago)
- Last Synced: 2024-04-25T17:43:25.388Z (about 2 years ago)
- Topics: file-cache, ruby, ruby-gem
- Language: Ruby
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Kubo
Kubo is a Ruby gem to file cache easily.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'kubo'
```
And then execute:
$ bundle install
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)
# 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`.
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/evokelektrique/kubo.