Skip to content

GetOrLoad has a strange ok return value #28

@judofyr

Description

@judofyr

GetOrLoad returns (value V, err error, ok bool), but the ok parameter is a bit strange:

  • If the value was in cache then it's always true.
  • If the value wasn't in cache then it returns the shared flag from the single flight group.

I'm not really sure what I'm supposed to do with this return value. I think it would be more valuable for the return value to be (value V, err error, shared bool) and then return false here if it was in the cache. That makes it possible for me to detect three different scenarios:

  1. Loader invoked => This request had to wait for the loader.
  2. Loader not invoked + shared: false => This request was served fully from the cache.
  3. Loader not invoked + shared: true => This request had to wait in the queue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions