mirror of
https://github.com/zhigang1992/workers-graphql-server.git
synced 2026-01-12 09:43:41 +08:00
Remove KV caching
We don't have the tooling to properly support this - I'd like to return to it in a couple months, but this project is functional without the cache, too!
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
const { ApolloServer, gql } = require('apollo-server-cloudflare')
|
||||
const { graphqlCloudflare } = require('apollo-server-cloudflare/dist/cloudflareApollo')
|
||||
const { PokemonAPI } = require('../pokeapi')
|
||||
const { KVCache } = require('../kv-cache')
|
||||
|
||||
const typeDefs = gql`
|
||||
type PokemonSprites {
|
||||
@@ -40,7 +39,6 @@ const server = new ApolloServer({
|
||||
typeDefs,
|
||||
resolvers,
|
||||
introspection: true,
|
||||
cache: new KVCache(),
|
||||
dataSources: () => ({
|
||||
pokemonAPI: new PokemonAPI(),
|
||||
}),
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
class KVCache {
|
||||
get(key) {
|
||||
return GRAPHQL_ON_WORKERS.get(key)
|
||||
}
|
||||
|
||||
set(key, value, options) {
|
||||
const opts = {}
|
||||
const ttl = options && options.ttl
|
||||
if (ttl) {
|
||||
opts.expirationTtl = ttl
|
||||
}
|
||||
return GRAPHQL_ON_WORKERS.put(key, value, opts)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { KVCache }
|
||||
@@ -4,4 +4,3 @@ private = false
|
||||
route = "yoururl.com/*"
|
||||
account_id = "abc123"
|
||||
zone_id = "def456"
|
||||
kv-namespaces = ["GRAPHQL_ON_WORKERS"]
|
||||
|
||||
Reference in New Issue
Block a user