Go to main content

dbhash_put

Insert a value in the database.

DBHASH_PUT

NAME

dbhash_put - Insert a value in the database.

SYNOPSIS

dbhash_put (db:pointer, key:string, value:string [,mode:integer]);

DESCRIPTION

This function is used to put a key/data(nosql) in the database.

The following definitions could be used for key/data operation:

Mode can be:

    %define  GDBM_INSERT  0;        /* Never replace old data with new. */
    %define  GDBM_REPLACE 1;        /* Always replace old data with new. */

PARAMETERS

mode
Specify mode. Default is GDBM_REPLACE.

RETURN

If a reader calls dbhash_put the return value will be -1. If called with GDBM_INSERT and key is in the database, the return value will be 1. Otherwise, the return value is 0.

MODULES

To use this module, you must specify the following in /usr/local/website/site.conf:

Module hash {
    Library : "/usr/local/lib/libsndbhash.so"
    Init : "sndbhash_init"
}

EXAMPLES

hash = dbhash_open("/hash/test.db");

ret = dbhash_put(db:hash,key:"cookie",value:"aurhfqiuwrhf");

SEE ALSO

{{ include("includes/dbhash.sn") }}

AUTHOR

Written by Pierre Laplante, <laplante@sednove.com>

MODIFICATIONS

1.0 2015-02-09 21:24:14 laplante@sednove.com

Edit

© 2024 extenso Inc. All rights reserved.