Ignore:
Timestamp:
02/19/08 15:44:50 (4 years ago)
Author:
Tomash Brechko <tomash.brechko@…>
Branches:
master-v0.7, master-v0.6, memcached_hash, upstream_count_limit
Children:
11531c
Parents:
a64318
git-author:
Tomash Brechko <tomash.brechko@…> (02/19/08 15:44:50)
git-committer:
Tomash Brechko <tomash.brechko@…> (02/19/08 15:44:50)
Message:

Add optional variable $memcached_namespace.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/src/http/modules/ngx_http_memcached_module.c

    r0019fc r7bf8e1  
    1414    ngx_http_upstream_conf_t   upstream; 
    1515    ngx_int_t                  index; 
     16    ngx_int_t                  ns_index; 
    1617} ngx_http_memcached_loc_conf_t; 
    1718 
     
    150151 
    151152static ngx_str_t  ngx_http_memcached_key = ngx_string("memcached_key"); 
     153static ngx_str_t  ngx_http_memcached_ns = ngx_string("memcached_namespace"); 
    152154 
    153155 
     
    227229{ 
    228230    size_t                          len; 
    229     uintptr_t                       escape; 
     231    uintptr_t                       escape, ns_escape = 0; 
    230232    ngx_buf_t                      *b; 
    231233    ngx_chain_t                    *cl; 
    232234    ngx_http_memcached_ctx_t       *ctx; 
    233     ngx_http_variable_value_t      *vv; 
     235    ngx_http_variable_value_t      *vv, *ns_vv; 
    234236    ngx_http_memcached_loc_conf_t  *mlcf; 
    235237 
     
    246248    escape = 2 * ngx_escape_uri(NULL, vv->data, vv->len, NGX_ESCAPE_MEMCACHED); 
    247249 
    248     len = sizeof("get ") - 1 + vv->len + escape + sizeof(CRLF) - 1; 
     250    ns_vv = ngx_http_get_indexed_variable(r, mlcf->ns_index); 
     251 
     252    if (ns_vv != NULL && !ns_vv->not_found && ns_vv->len != 0) { 
     253        ns_escape = 2 * ngx_escape_uri(NULL, ns_vv->data, 
     254                                       ns_vv->len, NGX_ESCAPE_MEMCACHED); 
     255    } 
     256 
     257    len = sizeof("get ") - 1 + ns_vv->len + ns_escape 
     258                             + vv->len + escape + sizeof(CRLF) - 1; 
    249259 
    250260    b = ngx_create_temp_buf(r->pool, len); 
     
    268278 
    269279    ctx->key.data = b->last; 
     280 
     281    if (ns_vv != NULL && !ns_vv->not_found && ns_vv->len != 0) { 
     282        if (ns_escape == 0) { 
     283            b->last = ngx_copy(b->last, ns_vv->data, ns_vv->len); 
     284        } else { 
     285            b->last = (u_char *) ngx_escape_uri(b->last, ns_vv->data, 
     286                                                ns_vv->len, 
     287                                                NGX_ESCAPE_MEMCACHED); 
     288        } 
     289    } 
    270290 
    271291    if (escape == 0) { 
     
    525545     * 
    526546     *     conf->index = 0; 
     547     *     conf->ns_index = 0; 
    527548     */ 
    528549 
     
    629650    } 
    630651 
     652    lcf->ns_index = ngx_http_get_variable_index(cf, &ngx_http_memcached_ns); 
     653 
     654    if (lcf->ns_index == NGX_ERROR) { 
     655        return NGX_CONF_ERROR; 
     656    } 
     657 
    631658    return NGX_CONF_OK; 
    632659} 
Note: See TracChangeset for help on using the changeset viewer.