{"push_id":1030023347,"size":3,"distinct_size":3,"ref":"refs/heads/refactor-feature-caching","head":"e8870937b7e58f3514ea9556527503299e6f22d8","before":"223507d6c388752b7ea9ea7486a6fb6cc4c83f53","commits":[{"sha":"10479a72a2c61d0a28918876c6f4bb8889342f19","author":{"email":"2fe3c805070d242647c7870e431812e6fcfdbf83@chdorner.com","name":"chdorner"},"message":"Refactor feature caching to be lazy-loaded\n\nInstead of loading all features from the database when the Client is\ninitialized, this will only load the features from the database when the\nactual state of the flags is accessed through either `enabled` or `all`.\n\nThe reason for this refactoring is that we have long-lived requests in\nthe `streamer` and package, and for the workers. These requests live for\nas long as the Python process does, which means that we have to manually\ninvalidate the cache when a new chunk of work is about to get handled.\n\nWith the old caching mechanism, this meant that the only way to\ninvalidate the cache is to load the state of the flags from the\ndatabase. This solution however adds more roundtrips to Postgres, since\nmost websocket work and worker jobs don't rely on features at the\nmoment, so there's no need to load them from the database. But to\nprevent weird behaviour in the future, there is a need to invalidate the\ncache.\n\nThis commit changes the caching mechanism to only load the state of the\nflags from the database when the state of one particular feature is\naccessed. Thus allowing us to have a `clear()` method that only resets\nthe internal caching variable to an empty dictionary.\n\nThe methods that rely on the cache being loaded will now first check if\nthe cache is already loaded, if not, they will call `load()` first, and\nthen access the flags through the fresh cache.","distinct":true,"url":"https://api.github.com/repos/hypothesis/h/commits/10479a72a2c61d0a28918876c6f4bb8889342f19"},{"sha":"6425952e9b4ba37cdcf15e45830056c74b5bcee2","author":{"email":"2fe3c805070d242647c7870e431812e6fcfdbf83@chdorner.com","name":"chdorner"},"message":"Manually clear features cache in workers","distinct":true,"url":"https://api.github.com/repos/hypothesis/h/commits/6425952e9b4ba37cdcf15e45830056c74b5bcee2"},{"sha":"e8870937b7e58f3514ea9556527503299e6f22d8","author":{"email":"2fe3c805070d242647c7870e431812e6fcfdbf83@chdorner.com","name":"chdorner"},"message":"Manually clear features cache in websockets server","distinct":true,"url":"https://api.github.com/repos/hypothesis/h/commits/e8870937b7e58f3514ea9556527503299e6f22d8"}]}