Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

kj/lucid-shopify-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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’.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages