Readers Writer Lock in Redis

A Readers-Writer Lock in Redis which can be utilized by proceesses across different servers.


Algorithm

acquire_read_lock:
  mutex_lock_acquire and not writer_waiting
  reader_count ++
  mutex_lock_release

release_read_lock:
  mutex_lock_acquire
  reader_count --
  if reader_count == 0:
  notify_all
  mutex_lock_release

acquire_writer_lock:
  mutex_lock_acquire
  while reader_count > 0:
  writer_waiting = true
  wait

release_writer_lock:
  writer_waiting = false
  mutex_lock_release

wait:
  mutex_lock_release
  wake_signal
  mutex_lock_acquire

What does it have inside?


You can access the github repository here and the documentation here.

Kunal Lillaney

Kunal Lillaney

rss facebook twitter github youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora