Repository is archived
No commit activity in last 3 years
No release in over 3 years
Cache Shopify API data
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.8
= 0.67

Runtime

~> 0.5
~> 4.1
 Project Readme

lucid-shopify-cache

Installation

Add the gem to your ‘Gemfile’:

gem 'lucid-shopify'
gem 'lucid-shopify-cache'

Usage

Make a cached GET request

require 'lucid/shopify/cached_get'

cached_get = Lucid::Shopify::CachedGet.new

args = [request_credentials, 'orders', fields: %w(id tags)]

cached_get.(*args)
cached_get.(*args) # fetched from the cache

To clear the cache:

cached_get.clear(*args)

Example: shop attributes

args = [request_credentials, 'shop', {}]

cached_get.(*args)['shop']

For the next hour, the data will be cached.

You might want to set the TTL to a high value and clear it only when shop data actually changes. In this case, set up a ‘shop/update’ webhook which calls:

cached_get.clear(*args).(*args)

TTL

The default cache TTL is 3600 seconds (one hour), but this can be changed by setting the environment variable ‘LUCID_SHOPIFY_CACHE_TTL’.