stream {
    server
{
        listen
1234;

        content_by_lua_block
{
               
local settings = ngx.shared.settings
                settings
:set("test", "stream lua")
       
}
   
}
}

http
{
    lua_shared_dict settings
50m;
    server
{
        listen
1235;
       
        location
/ {
            content_by_lua_block
{
               
local settings = ngx.shared.settings
               
--settings:set("test", "http lua")
               
local test = settings:get("test")
                ngx
.say(test)
           
}        
       
}    
   
}
}

本来是想实现一个tcp server,客户端发送的一些数据能在http里共享。
现在看stream和http是完全分离的,不能共享dict。有其他方法实现吗?
    Hello!
    
    2016-02-17 23:40 GMT-08:00 Millken Chen:
    >
    > 本来是想实现一个tcp server,客户端发送的一些数据能在http里共享。
    > 现在看stream和http是完全分离的,不能共享dict。有其他方法实现吗?
    >
    
    是的,目前是完全分离的。待未来 ngx_http_lua_module 和 ngx_stream_lua_module 通过一个
    ngx_meta_lua_module 来共享这部分代码以后,就可以实现 lua_shared_dict 的共享了。
    
    Regards,
    -agentzh
    


      在 2016年2月18日星期四 UTC+8下午3:40:31,Millken Chen写道:
      stream {
          server
      {
              listen
      1234;

              content_by_lua_block
      {
                     
      local settings = ngx.shared.settings
                      settings
      :set("test", "stream lua")
             
      }
         
      }
      }

      http
      {
          lua_shared_dict settings
      50m;
          server
      {
              listen
      1235;
             
              location
      / {
                  content_by_lua_block
      {
                     
      local settings = ngx.shared.settings
                     
      --settings:set("test", "http lua")
                     
      local test = settings:get("test")
                      ngx
      .say(test)
                 
      }        
             
      }    
         
      }
      }

      本来是想实现一个tcp server,客户端发送的一些数据能在http里共享。
      现在看stream和http是完全分离的,不能共享dict。有其他方法实现吗?
        6 years later

        this repository is a part of https://github.com/api7/apisix-nginx-module
        To realize the openresty/meta-lua-nginx-module#76

        how to use
        base openresty official 1.19.9.1 version
        Follow the steps below:
        cd apisix-nginx-module/patch
        ./patch.sh ThePathOfYourOpenRestySrcDirectory
        /configure --add-module=../apisix-nginx-module/src/meta
        make -j10

          Write a Reply...