Giter Club home page Giter Club logo

Comments (5)

julik avatar julik commented on June 1, 2024

It looks like this loops back into #190 but I haven't found how this combines with Flipper.enabled? and actors 🤔

from flipper.

bkeepers avatar bkeepers commented on June 1, 2024

@julik by default, Flipper will preload and memoize all gate data for the duration of each web request. So there should be only one network call to load flipper data, regardless of actor or number of times features are checked. You can read more about those optimizations here: https://www.flippercloud.io/docs/optimization

You can set Flipper.memoize = true in console to see it working. In the screenshot below, notice:

  1. Repeated calls to enabled? are trigging ActiveRecord queries
  2. Turned on memoization with Flipper.memoize = true
  3. After the next enabled? call there are no more queries. This would be true even for different actors.

image

So you shouldn't need any custom code to memoize. Let me know if I'm not understanding or you still have a question that I'm not answering.

from flipper.

julik avatar julik commented on June 1, 2024

Oh my @bkeepers thank you. I forgot to do one crucial thing - update the gems before asking. This makes so much sense. So do I understand correctly that:

  • Features can be memoized, and their feature gates and "actor" definitions too? Just the definitions are runnable code. But there is no memoization for the feature flag values for a particular actor.
  • When memoized, there won't be requests to the feature store, but the feature gates will still be applied at runtime? So when I call enabled? and, say, a "admin group membership" check that we have queries the DB, I will still end up with N+1 queries?

from flipper.

jnunemaker avatar jnunemaker commented on June 1, 2024

When memoized, there won't be requests to the feature store, but the feature gates will still be applied at runtime? So when I call enabled? and, say, a "admin group membership" check that we have queries the DB, I will still end up with N+1 queries?

Correct, any queries you have in groups will be invoked at runtime. Everything else will be preloaded.

This is why we're hardening expressions so that groups can someday no longer be needed. With expressions you can provide properties up front however you want and then know that flag evaluation will never invoke network calls.

from flipper.

julik avatar julik commented on June 1, 2024

Thank you gentlemen!

from flipper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.