コード例 #1
0
ファイル: gkvList.go プロジェクト: notalkingplz/rtcchat2
func main() {
	//var maxIdleTime int64 = 60*60*24	// 24 hours
	fmt.Println(TAG, "start...")
	rtcchat2.GkvInit()

	now := time.Now()
	rtcchat2.C.VisitItemsAscend([]byte(""), true, func(i *gkvlite.Item) bool {
		// This visitor callback will be invoked with every item
		// If we want to stop visiting, return false;
		key := string(i.Key)
		user := rtcchat2.GkvGet(key)

		// show the create-age and idle-age in seconds
		ageCreated := now.Unix() - user.Created.Unix()
		ageIdle := now.Unix() - user.LastAccessed.Unix()
		fmt.Println("Key", key,
			"Val", user.Value,
			"Crea", ageCreated,
			"Last", ageIdle,
			"C", user.Counter,
			user.AutoAnswer, user.Flag2, user.Flag3, user.Int1, user.Int2, user.Int3)
		/*if(ageIdle>maxIdleTime) {
			fmt.Println("Key",key,"is inactive too long; may be removed")
			rtcchat2.C.Delete(i.Key)
			rtcchat2.S.Flush()
			rtcchat2.F.Sync()
		}*/
		return true
	})
}
コード例 #2
0
ファイル: gkvDisplay.go プロジェクト: notalkingplz/rtcchat2
func main() {
	fmt.Println(TAG, "start...")
	rtcchat2.GkvInit()

	var user rtcchat2.UserInfo
	var key string

	key = "f3e2-01d2-1f66-0cd3"
	user = rtcchat2.GkvGet(key)
	fmt.Println(TAG, key, user.Value, user.Created, user.LastAccessed, user.Counter)

	key = "01d2-f3e2-d332-164d"
	user = rtcchat2.GkvGet(key)
	fmt.Println(TAG, key, user.Value, user.Created, user.LastAccessed, user.Counter)

	key = "e6a2-dde2-d1f2-1622"
	user = rtcchat2.GkvGet(key)
	fmt.Println(TAG, key, user.Value, user.Created, user.LastAccessed, user.Counter)

	key = "d9a6-c4e4-2231-8a3d"
	user = rtcchat2.GkvGet(key)
	fmt.Println(TAG, key, user.Value, user.Created, user.LastAccessed, user.Counter)
}