在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):LazyZhu/lua-resty-ssdb开源软件地址(OpenSource Url):https://github.com/LazyZhu/lua-resty-ssdb开源编程语言(OpenSource Language):Lua 100.0%开源软件介绍(OpenSource Introduction):Namelua-resty-ssdb - Lua ssdb client driver for the ngx_lua based on the cosocket API StatusThis library is considedb production ready. DescriptionThis Lua library is a SSDB client driver for the ngx_lua nginx module: http://wiki.nginx.org/HttpLuaModule This Lua library takes advantage of ngx_lua's cosocket API, which ensures 100% nonblocking behavior. Note that at least ngx_lua 0.5.14 or ngx_openresty 1.2.1.14 is required. SSDB is an open source, advanced key-value store server based on leveldb database: https://github.com/ideawu/ssdb Synopsis
MethodsAll of the SSDB commands have their own methods with the same name except all in lower case. You can find the complete list of SSDB commands here: https://github.com/ideawu/ssdb/wiki/Commands You need to check out this SSDB command reference to see what SSDB command accepts what arguments. The SSDB command arguments can be directly fed into the corresponding method call. For example, the "GET" SSDB command accepts a single key argument, then you can just call the "get" method like this:
Or, the "set" method with two arguments like this:
And, the "SCAN" ssdb command accepts three arguments, then you should call the "scan" method like this:
For example, "SET", "GET", "SCAN", and "RSCAN" commands correspond to the methods "set", "get", "scan", and "rscan". All ssdb command methods returns a Lua table and If ssdb command only results in "status reply"(such as A nil reply results in a See https://github.com/ideawu/ssdb/wiki/Commands for details regarding various SSDB reply types. In addition to all those ssdb command methods, the following methods are also provided: new
Creates a ssdb object. In case of failures, returns connect
Attempts to connect to the remote host and port that the ssdb server is listening to. Before actually resolving the host name and connecting to the remote backend, this method will always look up the connection pool for matched idle connections created by previous calls of this method. An optional Lua table can be specified as the last argument to this method to specify various connect options:
set_timeout
Sets the timeout (in ms) protection for subsequent operations, including the set_keepalive
Puts the current SSDB connection immediately into the ngx_lua cosocket connection pool. You can specify the max idle timeout (in ms) when the connection is in the pool and the maximal size of the pool every nginx worker process. In case of success, returns Only call this method in the place you would have called the get_reused_times
This method returns the (successfully) reused times for the current connection. In case of error, it returns If the current connection does not come from the built-in connection pool, then this method always returns close
Closes the current ssdb connection and returns the status. In case of success, returns init_pipeline
Enable the ssdb pipelining mode. All subsequent calls to SSDB command methods will automatically get cached and will send to the server in one run when the This method always succeeds. If the ssdb object is already in the SSDB pipelining mode, then calling this method will discard existing cached SSDB queries. commit_pipeline
Quits the pipelining mode by committing all the cached SSDB queries to the remote server in a single run. All the replies for these queries will be collected automatically and are returned as if a big multi-bulk reply at the highest level. This method returns cancel_pipeline
Quits the pipelining mode by discarding all existing cached SSDB commands since the last call to the This method always succeeds. If the ssdb object is not in the SSDB pipelining mode, then this method is a no-op. add_commands
Adds new ssdb commands to the
DebuggingIt is usually convenient to use the lua-cjson library to encode the return values of the ssdb command methods to JSON. For example,
Limitations
InstallationIf you are using the ngx_openresty bundle (http://openresty.org ), then
you need to copy
If you're using your own nginx + ngx_lua build, then you need to configure the lua_package_path directive to add the path of your lua-resty-ssdb source tree to ngx_lua's LUA_PATH search path, as in
TODOCommunityEnglish Mailing ListThe openresty-en mailing list is for English speakers. Chinese Mailing ListThe openresty mailing list is for Chinese speakers. Bugs and PatchesPlease report bugs or submit patches by
AuthorLazyZhu (lazyzhu.com) [email protected] Yichun "agentzh" Zhang (章亦春) [email protected], CloudFlare Inc. Copyright and LicenseThis module is licensed under the BSD license. Copyright (C) 2012-2013, by Yichun Zhang (agentzh) [email protected], CloudFlare Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. See Also
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论