books
Free Books / Computers / Practical mod_perl /

previous page: 17.2.2. Filesystem Databases
  
page up: Practical mod_perl | by Stas Bekman and Eric Cholet
  
next page: 17.2.4. Relational Databases

17.2.3. DBM Databases




Description

This section is from the "Practical mod_perl" book, by Stas Bekman and Eric Cholet. Also available from Amazon: Practical mod_perl

DBM databases are very similar to flat-file databases, but if all you need is to store the key/value pairs, they will do it much faster. Their use is much simpler, too. Perl uses tie( ) to interact with DBM databases, and you work with these files as with normal hash data structures. When you want to store a value, you just assign it to a hash tied to the DBM database, and to retrieve some data you just read from the hash.

A good example is session tracking: any user can connect to any of several mod_perl processes, and each process needs to be able to retrieve the session ID from any other process. With DBM this task is trivial. Every time a lookup is needed, tie the DBM file, get the shared lock, and look up the session_id there. Then retrieve the data and untie the database. Each time you want to update the session data, you tie the database, acquire an exclusive lock, update the data, and untie the database. It's probably not the fastest approach, and probably not the best one if you need to store more than a single scalar for each record, but it works quite well.

In Chapter 20 we give some important background information about DBM files and provide a few examples of how you can benefit from usingDBM files under mod_perl.

 

Continue to:

  • prev: 17.2.2. Filesystem Databases
  • Table of Contents
  • next: 17.2.4. Relational Databases

Books by Stas Bekman:















TOP
previous page: 17.2.2. Filesystem Databases
  
page up: Practical mod_perl | by Stas Bekman and Eric Cholet
  
next page: 17.2.4. Relational Databases

Topics

  • Animals
  • Architecture
  • Arts
  • Business
  • Computers
  • Crafts
  • Fairy Tales
  • Finance
  • Flora and Plants
  • Cooking
  • Gardening
  • Health and Healing
  • History
  • Home Improvements
  • Languages
  • New Age
  • Novels
  • Real Estate
  • Reference
  • Religion
  • Science
  • Society
  • Sports
  • Travel
  • Outdoors


Search

My Books

Headaches Begone! A Systemic Approach To Healing Your Headaches
Don't Let Your Bike Seat Ruin Your Sex Life Book

Discover

  • Answers FAQ

[ Privacy Policy | Terms of Use | About Us | Search ]

© 2007-2021 StasoSphere.com