You can access to the Redis from the Cloudflare Workers using REST API of Upstash.
This tutorial explains the required steps to implement a Cloudflare Workers function that shows a page counter where the state is stored in Redis.
If you do not have one, create a database following this guide. In the database page, click the button
REST API and copy the REST URL.
Normally, it is best to create a Cloudflare Workers project using cli (wrangler) as described here. But you can try our example in the Workers Playground. Copy and paste the below code to the Workers Playground but you need to change the enpoint including the token:
The above code simply increments a Redis counter with each Cloudflare Workers request and return the current value.