Documentation ¶
Overview ¶
Package gdbm provides support for the GNU database manager.
Index ¶
- Constants
- type Config
- type Database
- func (d *Database) Close()
- func (d *Database) Exists(key []byte) bool
- func (d *Database) Fetch(key []byte) (value []byte)
- func (d *Database) File() string
- func (d *Database) Iterate(callback func(key []byte) (cont bool))
- func (d *Database) Reorganize()
- func (d *Database) Store(key, data []byte)
- func (d *Database) Sync()
- type Mode
Constants ¶
const ( // Open as a reader. Reader Mode = C.GDBM_READER // Open as a writer. The database must already exist. Writer = C.GDBM_WRITER // Open as a writer and create the database if it does not exist. Create = C.GDBM_WRCREAT // Open as a writer and create a new database regardless if one already exists. ForceCreate = C.GDBM_NEWDB )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Name of the database file. File string // Permission bits to use when creating a new database file. Perm int // How to open the database. See the documentation for the Mode type. Mode Mode // If true, all database operations will be synchronized to the disk. Sync bool // If true, no file locking will be performed on the database. DontLock bool // When creating new databases, BlockSize refers to the size of a single // transfer from disk to memory. The minimum value is 512. If BlockSize // is zero, then the file system default will be used. BlockSize int // CacheSize sets the size of the internal bucket cache. If zero, the cache size // will be set to 100. CacheSize int }
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func Open ¶
Opens a database with the default options. The database will be created if it does not exist (with permission bits 0666, before umask).
func OpenConfig ¶
Opens a database using the given configuration options.
func (*Database) Close ¶
func (d *Database) Close()
Closes the database and releases all associated resources.
func (*Database) Fetch ¶
Returns the data associated with a given key, or nil if the key is not present in the database.
func (*Database) Iterate ¶
Iterates through all the keys in the database. The callback will be called for each key. The callback should return true unless it wants to cancel the iteration. Keys will be traversed in an unspecified order.
func (*Database) Reorganize ¶
func (d *Database) Reorganize()
Reorganizes the database file in order to reduce its size by reusing free space. This should be used very infrequently, and will only be useful after a lot of deletions have been made.