Git Product home page Git Product logo

Comments (1)

niho avatar niho commented on July 4, 2024

The Redis client is unable to perform set operations (sdiff, sunion, sinter) on pairs of keys that are stored in separate Redis instances when running a distributed setup. To handle this edge case Related instead fetches both keys and performs the set operations locally, which is somewhat slower, but will always work. This is explicitly only done when the Redis client raises a Redis::Distributed::CannotDistribute exception in order to not degrade the performance of the general case.

The point of using alias_method_chain and separating the implementation in pairs of methods (e.g. union and union_with_distributed_fallback) is simply to keep the code as clean and maintainable as possible, clearly separating out distinct concerns. It also allows you to call the automatically generated method union_without_distributed_fallback which can be useful in certain cases.

I guess this can be changed to use the prepend method instead of alias_method_chain, which seems to be the preferred way of doing these kind of things in Ruby 2.0. So moving the *_with_distributed_fallback methods to a separate module (Related::Node::DistributedFallback might be a good name) and then adding a prepend DistributedFallback to Related::Node::Query would probably do the trick.

Caveat: I'm not really familiar with the new prepend method, as I haven't had the opportunity to actually use it. Thus my suggestion on how to use it might be uninformed and/or stupid. Take it with a grain of salt. That said, it seems like the way forward.

from related.

Related Issues (12)

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.