The project is in a healthy, maintained state
Library for interacting with Cloudflare Workers KV Storage and configuring connection from a Rails application.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 2.0
 Project Readme

CloudflareStorage

CloudflareStorage is a simple gem for interacting with the Cloudflare Workers KV Storage from a Rails application.

It was designed to let you get started with minimal configuration.

Read a more detailed writeup here.

Installation

Add this line to your application's Gemfile:

gem 'cloudflare_storage'

And then run:

bundle

Or install it yourself:

gem install cloudflare_storage 

Usage

Configure credentials with an initializer. For example:

# config/initializers/cloudflare_storage.rb
CloudflareStorage.configure do |config|
    config.account_id = Rails.application.credentials.cloudflare.account_id
    config.namespace_id = Rails.application.credentials.cloudflare.namespace_id
    config.token = Rails.application.credentials.cloudflare.token
  end
end

Now you can simply call CloudflareStorage in your code to read, write, and list from Workers KV storage. I.e.

CloudflareStorage.write('foo', 'bar')

CloudflareStorage.read('foo') # Returns 'bar'

CloudflareStorage.list('fo') # Lists all keys starting with 'fo'

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, then create a new git tag and push it. Github actions will take care of the rest.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/geetotes/cloudflare_storage.

License

The gem is available as open source under the terms of the MIT License.

Alternatives

There are other gems out there that encompass the whole of the Cloudflare API. You should look to those if you're planning on using more than just Workers KV storage in your project.