Skip to content

Instantly share code, notes, and snippets.

@asoong
Created July 19, 2019 23:27
Show Gist options
  • Save asoong/495c94bc8450854963ff3f74cf8ae579 to your computer and use it in GitHub Desktop.
Save asoong/495c94bc8450854963ff3f74cf8ae579 to your computer and use it in GitHub Desktop.
def weth_price
weth_price = @redis.get(WETH_PRICE_REDIS_KEY)
if weth_price.blank?
weth_price = update_cache_for_weth_price_from_db
end
weth_price
end
def update_cache_for_weth_price_from_db
weth = @coin_repository.weth
weth_price_usd = weth.price_usd
@redis.setex(WETH_PRICE_REDIS_KEY,
WETH_PRICE_REDIS_TTL,
weth_price_usd)
weth_price_usd
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment