Comments (1)
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)
- Allow multiple storage backends for Node data
- Sharding
- Related::Affinity module
- EventMachine support
- Use breath first instead of depth first in #path_to HOT 1
- Bi-directional Node::Relationship for tags? HOT 2
- Related::Relationship can become semi-inconsistent HOT 1
- related/follower incompatible with devise HOT 1
- How could I destroy Relationship? HOT 1
- License missing from gemspec HOT 2
- per_page does not work properly without specifying page
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from related.