GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lmdbxx/example.cc at master · drycpp/lmdbxx

Expand file tree

/

example.cc

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
34 lines (28 loc) · 1.03 KB
/

example.cc

Copy path

File metadata and controls

34 lines (28 loc) · 1.03 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* This is free and unencumbered software released into the public domain. */
#include <cstdio>
#include <cstdlib>
#include <lmdb++.h>
int main() {
/* Create and open the LMDB environment: */
auto env = lmdb::env::create();
env.set_mapsize(1UL * 1024UL * 1024UL * 1024UL); /* 1 GiB */
env.open("./example.mdb", 0, 0664);
/* Insert some key/value pairs in a write transaction: */
auto wtxn = lmdb::txn::begin(env);
auto dbi = lmdb::dbi::open(wtxn, nullptr);
dbi.put(wtxn, "username", "jhacker");
dbi.put(wtxn, "email", "[email protected]");
dbi.put(wtxn, "fullname", "J. Random Hacker");
wtxn.commit();
/* Fetch key/value pairs in a read-only transaction: */
auto rtxn = lmdb::txn::begin(env, nullptr, MDB_RDONLY);
auto cursor = lmdb::cursor::open(rtxn, dbi);
std::string key, value;
while (cursor.get(key, value, MDB_NEXT)) {
std::printf("key: '%s', value: '%s'\n", key.c_str(), value.c_str());
}
cursor.close();
rtxn.abort();
/* The enviroment is closed automatically. */
return EXIT_SUCCESS;
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.