cybozu / libyrmcds Goto Github PK
View Code? Open in Web Editor NEWA memcached client library for C/C++. Best suited to yrmcds.
Home Page: http://cybozu.github.io/libyrmcds/
License: Other
A memcached client library for C/C++. Best suited to yrmcds.
Home Page: http://cybozu.github.io/libyrmcds/
License: Other
README.md states:
Although the socket used in libyrmcds is blocking, receiving results from the server is separated from the sending operations. You can even use a different thread to receive results asynchronously.
The design is elegant, works like a charm. However it seems like that there is no way to gracefully shutdown the receiver thread.
IMO, yrmcds_recv
function should return (presumably with an error code like YRMCDS_INTERRUPTED
) when recv(2)
returns EINTR
, so that applications can do whatever they want.
Now, libyrmcds always links to LZ4, however it is often the case that the application needs to compression at all.
It would be great if the dependency could be optionally turned off at compile time.
Since 4.11, Linux introduces a new socket option TCP_FAST_OPEN_CONNECT
to ease implementation of TCP Fast Open.
Real world example in curl:
curl/curl@979b012
libyrmcds is a TCP client so this is worthwhile.
It would be great if portability.h gets renamed to yrmcds_portability.h
or something, since the file is internal to libyrmcds.
To use libyrmcds we need to add source directory of libyrmcds to the include paths (since it is the directory that contains yrmcds.h). The existence of portability.h
in the same directory means that there would be a conflict if user has a header file with the same name.
This is kind of a nit-pick (and I am not suffering from the issue).
portability.h breaks on Solaris/SmartOS/Illumos as it assumes !(OSX || Linux) => BSD.
Solaris does not have sys/endian.h.
The patch below fixes this. I am using the macros {BE|LE}_IN{16|32|64} from Solaris' sys/byteorder.h which are a bit slower but can deal with unaligned access as the values might be read from a network buffer and not be guaranteed to be aligned on word boundaries.
--- /home/majid/portability.h.dist Fri Sep 11 11:56:21 2015
+++ /home/majid/portability.h Fri Sep 11 12:04:04 2015
@@ -29,6 +29,20 @@
# define le64toh(x) OSSwapLittleToHostInt64(x)
#elif defined(__linux__)
# include <endian.h>
+#elif defined(sun) /* Solaris */
+# include <sys/byteorder.h>
+# define htobe16(x) BE_16(x)
+# define htole16(x) LE_16(x)
+# define be16toh(x) BE_IN16(x)
+# define le16toh(x) LE_IN16(x)
+# define htobe32(x) BE_32(x)
+# define htole32(x) LE_32(x)
+# define be32toh(x) BE_IN32(x)
+# define le32toh(x) LE_IN32(x)
+# define htobe64(x) BE_64(x)
+# define htole64(x) LE_64(x)
+# define be64toh(x) BE_IN64(x)
+# define le64toh(x) LE_IN64(x)
#else // *BSD
# include <sys/endian.h>
#endif
Currently, libyrmcds supports binary protocol only.
To support text protocol as well, these may matter:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.