{"modulePath":"github.com/Evolution404/simcore","version":"v1.0.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package memorydb\n\nPackage memorydb implements the key-value database layer based on memory maps. 实现了所有接口的内存数据库,只用来进行测试 简而言之就是实现了KeyValueStore接口\n\n## Types\n\n```go\ntype Database struct {\n\t// contains filtered or unexported fields\n}\n```\nDatabase is an ephemeral key-value store. Apart from basic data storage functionality it also supports batch writes and iterating over the keyspace in binary-alphabetical order.\n\n```go\nfunc New() *Database\n```\nNew returns a wrapped map with all the required database interface methods implemented.\n\n```go\nfunc NewWithCap(size int) *Database\n```\nNewWithCap returns a wrapped map pre-allocated to the provided capcity with all the required database interface methods implemented. 初始化时指定了Cap大小\n\n```go\nfunc (db *Database) Close() error\n```\nClose deallocates the internal map and ensures any consecutive data access op failes with an error.\n\n```go\nfunc (db *Database) Compact(start []byte, limit []byte) error\n```\nCompact is not supported on a memory database, but there's no need either as a memory database doesn't waste space anyway.\n\n```go\nfunc (db *Database) Delete(key []byte) error\n```\nDelete removes the key from the key-value store.\n\n```go\nfunc (db *Database) Get(key []byte) ([]byte, error)\n```\nGet retrieves the given key if it's present in the key-value store.\n\n```go\nfunc (db *Database) Has(key []byte) (bool, error)\n```\nHas retrieves if a key is present in the key-value store. 判断数据库里是否保存有输入的key\n\n```go\nfunc (db *Database) Len() int\n```\nLen returns the number of entries currently present in the memory database.\n\nNote, this method is only used for testing (i.e. not public in general) and does not have explicit checks for closed-ness to allow simpler testing code.\n\n```go\nfunc (db *Database) NewBatch() ethdb.Batch\n```\nNewBatch creates a write-only key-value store that buffers changes to its host database until a final write is called. 创建一个只写的缓存区域,\n\n```go\nfunc (db *Database) NewIterator(prefix []byte, start []byte) ethdb.Iterator\n```\nNewIterator creates a binary-alphabetical iterator over a subset of database content with a particular key prefix, starting at a particular initial key (or after, if it does not exist). 创建一个Iterator对象,内部按照字典顺序保存了符合规则的key和value\n\n```go\nfunc (db *Database) Put(key []byte, value []byte) error\n```\nPut inserts the given value into the key-value store.\n\n```go\nfunc (db *Database) Stat(property string) (string, error)\n```\nStat returns a particular internal stat of the database. 内存数据库读取不到任何状态信息\n\n","path":"github.com/Evolution404/simcore/ethdb/memorydb","name":"memorydb","synopsis":"Package memorydb implements the key-value database layer based on memory maps.","isRedistributable":true}
