Skip to content

Commit

Permalink
Implement, document, and test the ?async and ?keepCache commands
Browse files Browse the repository at this point in the history
Issue #10
  • Loading branch information
gahr committed Apr 16, 2018
1 parent c28e5fb commit 23d5f55
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,20 @@ Either remove the result of the command identified by ***command identifier***
Switch on or off keeping results in the cache after the client has retrieven
them using the `result` method. By default, the results cache is enabled.

r ?keepCache

Query the current setting of `keepCache`.

r +async
r -async

Switch on or off the asynchronous operation mode. By default, asynchronous
operation is enabled.

r ?async

Query the current setting of `async`.

r pipeline script

Execute `script` in the caller scope while holding a Redis pipeline. All Redis
Expand Down
9 changes: 9 additions & 0 deletions doc/retcl.man
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ Turn on the use of the [emph {results cache}]. This is the default.
Turn off the use of the [emph {results cache}]. Results are removed from the
cache as soon as they are retrieved.

[call [emph r] [cmd ?keepCache]]

Return a boolean value indicating whether cache keeping is currently on or off.

[call [emph r] [cmd clearResult] [opt cmdId]]

Remove the result for [opt cmdId] from the [emph {results cache}] or clear it
Expand All @@ -161,6 +165,11 @@ a [emph {command identifier}].
Turn off asynchronous operation. In this mode, commands wait until a response
is received and return the body.

[call [emph r] [cmd ?async]]

Return a boolean value indicating whether asynchronous operation is currenty on
of off.

[call [emph r] [cmd errorHandler] [opt cmdPrefix]]

Set up an [emph {error handler}] to be called whenever an asynchronous error
Expand Down
14 changes: 14 additions & 0 deletions retcl.tm
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@ oo::class create retcl {
}
export -async

##
# Query the currenct asynchronous operation mode.
method ?async {} {
set async
}
export ?async

##
# Turn on keeping results in the cache.
method +keepCache {} {
Expand All @@ -253,6 +260,13 @@ oo::class create retcl {
}
export -keepCache

##
# Query the current cache keeping mode.
method ?keepCache {} {
set keepCache
}
export ?keepCache

##
# Setup and error callback or restore the default one ([error]). The
# cmdPrefix is passed an additional argument containing the error message.
Expand Down
23 changes: 23 additions & 0 deletions test/013-query-state.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# vim: ft=tcl ts=4 sw=4 expandtab:

tcltest::loadTestedCommands

tcltest::test query-state-1.2 {query default asynchronous state} -setup {
set r [retcl new]
} -body {
$r ?async
} -result {1}

tcltest::test query-state-1.2 {query false asynchronous state} -setup {
set r [retcl new]
} -body {
$r -async
$r ?async
} -result {0}

tcltest::test query-state-1.3 {query true asynchronous state} -setup {
set r [retcl new]
} -body {
$r +async
$r ?async
} -result {1}

0 comments on commit 23d5f55

Please sign in to comment.