Skip to content

graphboltdev/appsync-momento

Repository files navigation

This repo shows how you can use Momento as a cache layer with AWS AppSync resolvers, without using any Lambda function.

Overview

In this demo, we want to query the wikipedia API through AWS AppSync. In order to avoid overwhelming the wiki and return results faster for recurrent requests, we use Momento as a caching layer.

How It Works. TL;DR;

Under the hood, Momento works with an HTTP API which allows you to read and write cache items. This solution uses AppSync pipeline resolvers with an HTTP data source in order to get an item from cache. When there is a cache hit, the data is returned immediately. Otherwise, the data is resolved from Wikipedia and then saved into the cache.

graph TD;
    start([Start]) --> get[GetCacheItem]
    get --> hit_or_miss{Cache Hit?}
    hit_or_miss -- miss --> resolver[ResolveData] --> put[PutCacheItem] --> ret
    hit_or_miss -- hit --> ret
    ret([Return])

Considerations & Going Further.

This is a proof of concept for learning purpose only. Before using this for production workloads, there are some considerations and improvements that could be taken:

How to deploy?

  • Generate a momento token
  • Create a cache called wikipedia
  • Create a (secured) SSM parameter named /momento/cache/token and store your momento token in it.
  • npm i
  • npx sls deploy

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published