Skip to content

Cache the results from meetup.com #20

@zainab-ali

Description

@zainab-ali

The number of attendees is displayed on each meetup page. For example:

image

This number is obtained by the server through a request to meetup.com. The server makes a request to meetup.com each time it receives a request for an upcoming meetup. Hence, it makes a request each time someone visits a page under https://www.lsug.co.uk/meetups/....

The number of attendees of meetup doesn't change much. If many people visit the same page at once, we'll make many redundant requests to meetup.com for the same unchanging information.

It would be far better to cache the number of people. We can store it in memory in the server for one minute, and only request it if the stored value is older than one minute.

Potential Solution

A simple cache can probably be implemented with a cats-effect ref containing a Scala Map. This should be added to the lsug.Meetup class.

Tests

You should at least test that:

  • the value is re-requested after one minute
  • it isn't requested before one minute is up

You will need to mock meetup.com. This hasn't been done in the codebase yet, and you're free to experiment with mocking tools and patterns.

Prerequisites

It would be useful if you've dabbled a little in functional programming.

What you'll learn

  • The motivation behind caching.
  • The basics of cats-effect.
  • How to safely work with state in concurrent functional programming.
  • How to test with time and cats-effect
  • How to mock during testing

Getting started

Read our Contributor Guide to get set up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions