booksleeve


How to use a singleton for storing the RedisConnection with Booksleeve?


I'm using Booksleeve 1.1.0.6 (the latest nuget package).
I want so use a single connection for my whole Web Application so I'm storing it in a singleton:
public static RedisConnection Conn = RedisConfig.GetUnsecuredConnection(waitForOpen: true);
The RedisConfig.GetUnsecuredConnection method is the same as used in BookSleeve tests.
When I try to do an operation I get an InvalidOperationException: The queue is closed exception:
[InvalidOperationException: The queue is closed]
BookSleeve.MessageQueue.Enqueue(RedisMessage item, Boolean highPri) in C:\Dev\BookSleeve\BookSleeve\MessageQueue.cs:73
BookSleeve.RedisConnectionBase.ExecuteVoid(RedisMessage message, Boolean queueJump) in C:\Dev\BookSleeve\BookSleeve\RedisConnectionBase.cs:794
ASP.welisten_booksleevetests_aspx.SaveDictionaryToRedis(Dictionary`2 dictionary) +173
ASP.welisten_booksleevetests_aspx.Page_Load(Object sender, EventArgs e) +67
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064
I tried this with the waitForOpen parameter set to true and false
Here is the code I'm trying to execute:
private void SaveDictionaryToRedis(Dictionary<string, string> dictionary)
{
using (Mp.Step("Saving Data to Redis"))
{
using (RedisConfig.Conn)
{
RedisConfig.Conn.Strings.Set(DB, dictionary);
}
}
}
Depending on what was copied, it could be that there is a missing call to:
theConnection.Open();
which will open the connection and perform various handshakes. Thin the case of a singleton, this would be reasonable to do during the initializer.
However! Perhaps the problem here is that your second example is simply wrong. If Conn is, as described, a singleton - then it does not belong to that code, and you should not be using using. That would mean it is only usable once, and all subsequent access would fail. Just access the connection; no using here.

Related Links

BookSleeve ConnectionUtils with sentinel password
in booksleeve how do I iterate through all the keys in given db
Saving a collection of objects with BookSleeve
Booksleeve - Setting multiple Hash Values and retrieve them at once
How to use a singleton for storing the RedisConnection with Booksleeve?

Categories

HOME
fabricjs
porting
fpga
error-handling
owl-carousel
edge
parameters
visual-studio-emulator
banner
vert.x
nstableheaderview
32bit-64bit
siddhi
project-intu
datastage
azure-powershell
google-content-api
xmonad
foreign-keys
asciidoctor-pdf
hta
pchart
mongoid6
scriptella
tosca
jboss6.x
jquery-multiselect
sinch
cppreference
custom-controls
getpixel
python-import
least-squares
cd
modernizr
railstutorial.org
css-position
numberpicker
magento-1.9.3
escpos
placeholder
textsum
term
mongotemplate
payara-micro
pair-programming
qtranslate
semantic-logging
cup
er-diagram
rmongo
change-tracking
docpad
cubism.js
async.js
windows-azure-queues
jquery-jscrollpane
stream-processing
spreadjs
project-organization
yajsw
httpruntime.cache
themoviedb-api
roadkill-wiki
zen-cart
finalbuilder
shopizer
qtwebengine
punycode
iso-prolog
machine-instruction
xml-namespaces
matrix-inverse
authlogic
vbe
synapse
rolify
actiondispatch
cascadingdropdown
android-sdk-2.3
frameworkelementfactory
cakephp-1.2
wcf-configuration
josql
azman
w3c-geolocation
objective-j
hbm2java
data-mapping
lalr
dsl-tools
soappy
xslcompiledtransform

Resources

Encrypt Message