S
SolidJS2mo ago
gsoutz

cache doesnt revalidate inside websocket on('message')

I have this:
await make_game_move({ id: this.game_id, board, status, sans })

await revalidate(['get_game', 'get_pov'])

let asdf = await getGame(this.game_id)
console.log('after revalidate', this.game_id, 'sans', asdf!.sans)


this.publish_peers({ t: 'move', d: uci })
await make_game_move({ id: this.game_id, board, status, sans })

await revalidate(['get_game', 'get_pov'])

let asdf = await getGame(this.game_id)
console.log('after revalidate', this.game_id, 'sans', asdf!.sans)


this.publish_peers({ t: 'move', d: uci })
after await revalidate , getGame still returns the old value. This is running inside websocket's on('message').
1 Reply
gsoutz
gsoutzOP2mo ago
I changed it to this, and still doesn't update
await make_game_move({ id: this.game_id, board, status, sans })

await revalidate([getGame.keyFor(this.game_id), getPov.keyFor(this.game_id, this.user.id)])

let asdf = await getGame(this.game_id)
console.log(getGame.keyFor(this.game_id), ' after revalidate', this.game_id, 'sans', asdf!.sans)
console.log(getPov.keyFor(this.game_id, this.user.id))
await make_game_move({ id: this.game_id, board, status, sans })

await revalidate([getGame.keyFor(this.game_id), getPov.keyFor(this.game_id, this.user.id)])

let asdf = await getGame(this.game_id)
console.log(getGame.keyFor(this.game_id), ' after revalidate', this.game_id, 'sans', asdf!.sans)
console.log(getPov.keyFor(this.game_id, this.user.id))
Ok I think I figured out what cache is doing. It's a client side only feature, to keep the browser updated with changes. On the server side, I don't use cache. by instrumenting a refetch.
Want results from more Discord servers?
Add your server