<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andrew Moy on Medium]]></title>
        <description><![CDATA[Stories by Andrew Moy on Medium]]></description>
        <link>https://medium.com/@andrewmoy35?source=rss-51d0702410bc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JkPOUT-_0z-mNxxwwer4gA.png</url>
            <title>Stories by Andrew Moy on Medium</title>
            <link>https://medium.com/@andrewmoy35?source=rss-51d0702410bc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 17:35:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@andrewmoy35/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[DacheQL — Dashingly fast caching for your GraphQL queries]]></title>
            <link>https://medium.com/@andrewmoy35/dacheql-dashingly-fast-caching-for-your-graphql-queries-354353610697?source=rss-51d0702410bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/354353610697</guid>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[caching]]></category>
            <dc:creator><![CDATA[Andrew Moy]]></dc:creator>
            <pubDate>Wed, 12 Oct 2022 20:45:38 GMT</pubDate>
            <atom:updated>2022-10-13T20:19:32.563Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>DacheQL — Dashingly fast caching for your GraphQL queries</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*EXvWvr-0yFHk4ZuWw0voFQ.png" /><figcaption>DacheQL Version 1.0.0 is now released!</figcaption></figure><blockquote>DacheQL is an open-source developer tool that leverages the pinpoint accuracy of GraphQL’s queries and implements caching to improve your website’s query efficiency</blockquote><h3><strong>What is GraphQL?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*yic2L2WDUh-1RJMTlQcYUg.png" /><figcaption>GraphQL was released by Facebook in 2015</figcaption></figure><p>GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.</p><p>With GraphQL, you can specify what data you want to request from your API. You will get back exactly what you need, nothing more and nothing less. GraphQL queries always return predictable results.</p><h3><strong>What is a cache and why should you use it?</strong></h3><p>To put it simply, a cache can be defined as a high-speed data storage that stores a subset of data. This is so that future requests for that data are served up faster than by accessing the data’s primary storage location. But why should we use a cache? Does it really matter? <em>Yes it does!</em></p><blockquote><strong>79% </strong>of customers dissatisfied with a site’s load speed are less likely to return</blockquote><blockquote><strong>1 in 4 visitors </strong>will leave the site if it takes more than <strong>4 seconds</strong> to load</blockquote><blockquote>Even just a<strong> one </strong>second difference can result in <strong>7%</strong> decline in conversions</blockquote><p>Performance matters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*MOjRegqJGVxDVQnkGIVchQ.png" /></figure><p><strong>This is where DacheQL comes in!</strong></p><p>With DacheQL, you can automatically cache your GraphQL queries with some simple setup. If you are using DacheQL for the first time, please visit our website at <a href="http://dacheql.com/">http://dacheql.com/</a> to get a better understaning of DacheQL.</p><p>If you are ready to get started with DacheQL, please refer to our <a href="http://dacheql.com/docs">documentation</a>!</p><h3><strong>Installation and Setup</strong></h3><p>If you have not installed dacheql run the following command to install DacheQL into your application:<br> npm install dacheql</p><p>Now that you’ve installed DacheQL, in your server file you will have to require our middleware to handle GraphQL requests using the CommonJS format:<br>const dacheql = require(‘dacheql’);</p><h4><strong>Using DacheQL with Redis</strong></h4><p>DacheQL can be used two ways. The first way to use DacheQL is to use it with Redis, an open-source in memory data store that can be use for client side caching. You will want to make sure that you have Redis already installed on your computer. If you have not done so and wish to use Redis, please refer to the Redis documentation <a href="https://redis.io/docs/getting-started/">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*_Cfc0kROib5Sp28ICD4Atg.png" /><figcaption>Redis is an in memory data structure store</figcaption></figure><p>Once your Redis client has been connected, simply pass it into our DacheQL function as follows:<br>app.use(‘/graphql’, dacheQL({ redis } = {&lt;redis: client&gt;}, capacity, endpoint, TTL), expressGraphQL({ schema: schema, graphiql: true, }));</p><p>Simply replace &lt;redis: client&gt; with redis: *name of your client*</p><p>Since we are using Redis, the second parameter capacity does not matter as this is used for our LRU cache. You can simply replace capacity with something arbitrary like 50.</p><p>The third parameter is the endpoint where you are actually using GraphQL. This endpoint may be something like <a href="http://localhost:3000/graphql.">http://localhost:3000/graphql</a></p><p>Our last parameter TTL is for the time to live in the Redis cache. Simply pass in the time you want the query to last in the cache for in seconds. (Example: 50)Now you are good to use cache your GraphQL responses using Redis!</p><h4><strong>Using DacheQL with our custom LRU eviction policy cache</strong></h4><p>If you are not using Redis caching, DacheQL provides a middleware for caching using the server’s memory with our custom cache that behaves with an LRU eviction policy. The arguments you should input for this middleware are as follows:</p><p>For the first parameter, since you are not using Redis, simply pass in an empty object {}like so.</p><p>Next is the capacity you would like your cache to hold. This capacity refers to when our cache will begin evicting items. For example, if you set the capacity to 50, it will evict an item upon the 51st unique query. It should be noted that if you pass in a non-whole number, it will be rounded down for you. Non integers, negative numbers, and capacities below two will default to simply creating a GraphQL fetch without storing values in the cache.</p><p>The third parameter is the endpoint at which you are actually using GraphQL. For example, this may be <a href="http://localhost:3000/graphql.">http://localhost:3000/graphql.</a></p><p>Our last parameter is the Time to Live, or how long you want this specific query to last in your cache for. Since we aren’t using Redis here, just pass in anything for your TTL as our cache is not reliant on this information. Now you are good to cache your GraphQL responses with our custom LRU eviction policy!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hV6WiB7ETWin9XvlpxuF1w.gif" /><figcaption>Improved performance with DacheQL</figcaption></figure><h3><strong>How to contribute</strong></h3><p>If you wish to contribute to DacheQL, please visit DacheQL on <a href="https://github.com/oslabs-beta/DacheQL">GitHub</a>!</p><h3><strong>Closing Thoughts</strong></h3><p>In a fast paced technical environment, performance speed for websites matters more now than ever. DacheQL simplifies the caching process of your GraphQL queries in order for the devloper to increase their application performance. If you enjoyed our easy to use NPM package and this article, be sure to clap the article, follow the team on Linkedin and Github, and star our DacheQL <a href="https://github.com/oslabs-beta/DacheQL">GitHub</a>!</p><h3><strong>DacheQL Team</strong></h3><p>Andrew Moy @ <a href="https://www.linkedin.com/in/andrewmoy/">Linkedin</a> | <a href="https://github.com/Andrew-Moy">Github</a><br>ChunHao Zheng @ <a href="https://www.linkedin.com/in/chunhao-zheng-950a2718b/">Linkedin</a> | <a href="https://github.com/chunhz">Github</a><br>Ethan Chuang @ <a href="https://www.linkedin.com/in/ethan-chuang1/">Linkedin</a> | <a href="https://github.com/EthanChuang16">Github</a><br>Sandy Liu @ <a href="https://www.linkedin.com/in/sandy-liu-1ba488160/">Linkedin</a> | <a href="https://github.com/sandyliu31">Github</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=354353610697" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>