clojurewerkz / spyglass

A Clojure Memcached client (also: Couchbase, Kestrel). Built on top of SpyMemcached, supports ASCII and binary protocols, strives to be 100% feature complete.
http://clojurememcached.info
67 stars 17 forks source link

Is (c/text-connection endpoint) threadsafe? #31

Closed whamtet closed 6 years ago

whamtet commented 6 years ago

Thanks for the great client!

Is (c/text-connection endpoint) threadsafe or should I create a separate client for each thread? We've been getting some strange timeout messages.

michaelklishin commented 6 years ago

Thread safety is a property of an algorithm/workload and you haven't explained what your threads are going to do with the connection. Ultimately Spyglass connections are nothing more than Spymemcached connections and as far as I can tell Spymemcached was designed with concurrent access in mind.

whamtet commented 6 years ago

Thread safety means the connection can be safely accessed by more than one thread, it is not a property of algorithm / workload.

michaelklishin commented 6 years ago

@whamtet yes it is because what exactly your app does is incredibly important and that is specific to your algorithm/workload. Concurrency safety is not a universal property and one cannot claim that a library is universally safe or unsafe, even if it is as small as Spyglass, without knowing how exactly it is used.

michaelklishin commented 6 years ago

@whamtet consider how you'd answer the question if "safely used" is not known (since it is not known to me or any other reader who's not on the same project as you are). If the answer is "it depends on what exactly safely and used mean here", it's an algorithm/workload/use case property.