-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
357 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* 简单的基于 epoll 的事件处理; | ||
* set/get 命令 | ||
* 生成 rdb 文件(save 命令) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package dict | ||
|
||
type DictIterator struct { | ||
d *Dict | ||
index int | ||
table int | ||
safe bool | ||
entry, nextEntry *DictEntry | ||
// fingerprint int64 | ||
} | ||
|
||
func (di *DictIterator) Next() *DictEntry { | ||
for { | ||
if di.entry == nil { | ||
ht := &di.d.ht[di.table] | ||
if di.index == -1 && di.table == 0 { | ||
if di.safe { | ||
di.d.iterators++ | ||
} | ||
// else { | ||
// di.fingerprint = | ||
// } | ||
} | ||
di.index++ | ||
if di.index >= int(ht.size) { | ||
if di.d.isRehashing() && di.table == 0 { | ||
di.table++ | ||
di.index = 0 | ||
ht = &di.d.ht[1] | ||
} else { | ||
break | ||
} | ||
} | ||
di.entry = ht.table[di.index] | ||
} else { | ||
di.entry = di.nextEntry | ||
} | ||
if di.entry != nil { | ||
di.nextEntry = di.entry.next | ||
return di.entry | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.