Skip to content

Example of building a http client request caching backed by Redis using ZIO stack with the Sttp client.

Notifications You must be signed in to change notification settings

ianlintner/sttp-zio-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STTP ZIO Redis Request Caching

Example of building a http client request caching backed by Redis using ZIO stack with the Sttp client.

This is straightforward example ZIO service that takes in an STTP request and caches the body using the uri as cache key.

The service code.

Example Dependencies

To run the example you will need to use the docker-compose up to bring up the redis server.

Run the example

sbt run

Output should show the same message for 3 runs even though they are delayed by a 1 second.

timestamp=2023-05-09T18:54:14.336568Z level=INFO thread=#zio-fiber-15 message="Connected to the redis server with address localhost/127.0.0.1:6379." location=zio.redis.RedisConnectionLive.openChannel file=RedisConnectionLive.scala line=126
timestamp=2023-05-09T18:54:14.790617Z level=INFO thread=#zio-fiber-4 message="2023-05-09T13:01:44.881126-05:00" location=<empty>.Main.run file=Main.scala line=26
timestamp=2023-05-09T18:54:15.803653Z level=INFO thread=#zio-fiber-4 message="2023-05-09T13:01:44.881126-05:00" location=<empty>.Main.run file=Main.scala line=28
timestamp=2023-05-09T18:54:16.814158Z level=INFO thread=#zio-fiber-4 message="2023-05-09T13:01:44.881126-05:00" location=<empty>.Main.run file=Main.scala line=30

About

Example of building a http client request caching backed by Redis using ZIO stack with the Sttp client.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages