Hacker News new | ask | show | jobs
by CuriousNinja 1920 days ago
One of the examples on invalidating cache on write has the following code, which is buggy. If the DB call fails, then cache cache would have data that was never actually committed. Cache coherency is hard.

  def update_something_slow(thing_id, new_thing):
    my_cache.set_by_str(thing_id, new_thing)
    set_thing_in_a_database_layer(new_thing)