Sounds like a bug in Redis documentation, the await keyword is a used in 
{.async.} proc and only there. {.async.} is defined in asyncdispatch.

See asyncnet documentation 
[https://nim-lang.org/docs/asyncnet.html](https://nim-lang.org/docs/asyncnet.html)
    
    
    # Chat server
    
    import asyncnet, asyncdispatch
    
    var clients {.threadvar.}: seq[AsyncSocket]
    
    proc processClient(client: AsyncSocket) {.async.} =
      while true:
        let line = await client.recvLine()
        if line.len == 0: break
        for c in clients:
          await c.send(line & "\c\L")
    
    proc serve() {.async.} =
      clients = @[]
      var server = newAsyncSocket()
      server.setSockOpt(OptReuseAddr, true)
      server.bindAddr(Port(12345))
      server.listen()
      
      while true:
        let client = await server.accept()
        clients.add client
        
        asyncCheck processClient(client)
    
    asyncCheck serve()
    runForever()
    
    
    Run

Seems like the example should be rewritten to something similar to:
    
    
    import redis, asyncdispatch
    
    proc main(){.async.} =
      
      ## Open a connection to Redis running on localhost on the default port 
(6379)
      let redisClient = waitFor redis.openAsync()
      
      ## Set the key `nim_redis:test` to the value `Hello, World`
      asyncCheck redisClient.setk("nim_redis:test", "Hello, World")
      
      ## Get the value of the key `nim_redis:test`
      let value = await redisClient.get("nim_redis:test")
      
      assert(value == "Hello, World")
    
    asyncCheck main()
    
    
    Run

Reply via email to