Giter Club home page Giter Club logo

crdts's Introduction

CFRTS

Conflict Free Replicated Data Types

CFRTDS are used where concurrent updates to multiple replicas of the same data are needed, without coordination between the computers hosting the replicas.

Usage

Conflict-free Replicated Data Types (CRDTs) are used in systems with optimistic replication, where they take care of conflict resolution. CRDTs ensure that, no matter what data modifications are made on different replicas, the data can always be merged into a consistent state. This merge is performed automatically by the CRDT, without requiring any special conflict resolution code or user intervention.

Examples

Growth Only Counter

gc1 = GCounter(10)
''' add to the 4th , 2nd and 7 replica '''
gc1.increment(4) 
gc1.increment(2)
gc1.increment(7)
gc1.increment(4)

''' Returns 4 and displays the state of the counter '''
gc1.display()
print(gc1.query())
gc1.merge(gc2)
print(gc1.query())

PN Counter

p1 = PNCounter(3)
p2 = PNCounter(3)
p1.increment(1)
p1.increment(2)
p1.query()

p2.increment(3)

p1.display()
p2.display()
p1.merge(p2)
p1.display()
print(p1.query())

G-Only Set

gset1.addmember("A")
gset2.addmember("D")
gset1.addmember("C")
gset1.addmember("B")

print(gset1.compare(gset2))
print(gset2.compare(gset1))
print("")
gset2.display()
print("Looking up prior to merge" , gset1.lookup("D"))
print (gset1.merge(gset2))
print("Looking up after merge" , gset1.lookup("D"))
gset1.display()

References

crdts's People

Contributors

ckharide avatar

Watchers

 avatar

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.