Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Adding proper watch support and implements its dual, the unwatch command #33

Merged
merged 1 commit into from Dec 21, 2012

Conversation

Projects
None yet
2 participants
Contributor

dgvncsz0f commented Dec 20, 2012

This commit enables users to use the following pattern:

WATCH
GET
MULTI
EXEC/DISCARD

The old behavior have been kept intact, i.e., the multi function
continues to accept a list of keys to watch prior issuing the watch
command, although I believe this use should be deprecated.

The watch command may also be used standalone. In this case, users
should make use of the watch command to clear the `inTransaction'
state.

Some examples (the following assumes inlineCallbacks):

#1. Using watch/unwatch
tx = yield conn.watch(...)
...
yield tx.unwatch()

#2. Using watch/multi
tx = yield conn.watch(...)
...
yield tx.multi()
...
yield tx.commit()

#3. Using watch only
tx = yield conn.multi(...)
...
yield tx.commit()

#4. All together:
tx = yield conn.watch(...)
...
yield tx.multi()
...
yield tx.unwatch() # this will not clear
# the inTransaction state
...
yield tx.commit()

@dgvncsz0f dgvncsz0f Adding proper watch support and implements its dual, the unwatch command
This commit enables users to use the following pattern:

   WATCH
   GET
   MULTI
   EXEC/DISCARD

The old behavior have been kept intact, i.e., the multi function
continues to accept a list of keys to watch prior issuing the watch
command, although I believe this use should be deprecated.

The watch command may also be used standalone. In this case, users
should make use of the watch command to clear the `inTransaction'
state.

Some examples (the following assumes inlineCallbacks):

  # 1. Using watch/unwatch
  tx = yield conn.watch(...)
  ...
  yield tx.unwatch()

  # 2. Using watch/multi
  tx = yield conn.watch(...)
  ...
  yield tx.multi()
  ...
  yield tx.commit()

  # 3. Using watch only
  tx = yield conn.multi(...)
  ...
  yield tx.commit()

  # 4. All together:
  tx = yield conn.watch(...)
  ...
  yield tx.multi()
  ...
  yield tx.unwatch() # this will not clear
                     # the `inTransaction` state
  ...
  yield tx.commit()
52cdc1a
Collaborator

gleicon commented Dec 21, 2012

looks good to me, I don't know why travis broke on this one, trial ran ok on my setup. It would be good to add tests for watch + pools and watch + shard if possible, but not required. Add your name as contributor to the README on the next patch :).

EDIT: it seems that travis broke either on timeout or build. Ran trial again on my setup and it passed.

@gleicon gleicon added a commit that referenced this pull request Dec 21, 2012

@gleicon gleicon Merge pull request #33 from dgvncsz0f/master
Adding proper watch support and implements its dual, the unwatch command
d150918

@gleicon gleicon merged commit d150918 into fiorix:master Dec 21, 2012

1 check failed

default The Travis build failed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment