Created
July 19, 2019 23:27
-
-
Save asoong/495c94bc8450854963ff3f74cf8ae579 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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