Created
December 10, 2014 21:24
-
-
Save jatinn/692b19c62cd0929691a1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"time" | |
as "github.com/aerospike/aerospike-client-go" | |
) | |
const ( | |
HOSTNAME = "dev01" | |
PORT = 3000 | |
NAMESPACE = "nm1" | |
) | |
func main() { | |
client, err := as.NewClient(HOSTNAME, PORT) | |
if err != nil { | |
fmt.Println(err) | |
} | |
recordset, err := client.ScanAll(nil, NAMESPACE, "") | |
count := 0 | |
L: | |
for { | |
select { | |
case rec := <-recordset.Records: | |
if rec == nil { | |
break L | |
} | |
count++ | |
case err := <-recordset.Errors: | |
fmt.Println(err) | |
} | |
} | |
fmt.Println(count) | |
} |
This file contains hidden or 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
import aerospike | |
config = { | |
'hosts': [ | |
( 'dev01', 3000 ) | |
], | |
'policies': { | |
'timeout': 1000 # milliseconds | |
} | |
} | |
client = aerospike.client(config) | |
client.connect() | |
scan = client.scan('nm1', '') | |
count = 0 | |
def print_result((key, metadata, record)): | |
# print(key[2], record) | |
global count | |
count += 1 | |
scan.foreach(print_result) | |
print count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment