Giter VIP home page Giter VIP logo

redis's People

Contributors

araq avatar ba0f3 avatar bluemax75 avatar chrisnovakovic avatar dom96 avatar donpdonp avatar euantorano avatar jorisbontje avatar ringabout avatar samanthadoran avatar thomastjdev avatar treeform avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redis's Issues

Needs version bump

The current version 0.3.0 is quite broken (eg #24), but there are plenty of fixes since, it would be good to bump the version so nimble install redis gives a non broken version.

internal error: genLiteral: ty is nil

.nimble\pkgs\redis-0.2.0\redis.nim(309, 13) Error: internal error: genLiteral: ty is nil
Traceback (most recent call last)
nim.nim(133) nim
nim.nim(97) handleCmdLine
main.nim(162) mainCommand
main.nim(73) commandCompileToC
modules.nim(124) compileProject
modules.nim(71) compileModule
passes.nim(194) processModule
passes.nim(103) processTopLevelStmt
cgen.nim(1378) myProcess
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2285) expr
ccgstmts.nim(314) genVarStmt
ccgstmts.nim(298) genSingleVar
ccgstmts.nim(82) loadInto
ccgcalls.nim(559) genAsgnCall
ccgcalls.nim(187) genPrefixCall
ccgcalls.nim(170) genArg
cgen.nim(495) initLocExprSingleUse
ccgexprs.nim(2235) expr
ccgcalls.nim(548) genCall
ccgcalls.nim(195) genPrefixCall
cgen.nim(490) initLocExpr
ccgexprs.nim(2168) expr
cgen.nim(887) genProc
cgen.nim(852) genProcNoForward
cgen.nim(751) genProcAux
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2263) expr
ccgexprs.nim(2058) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2263) expr
(132 calls omitted) ...
ccgexprs.nim(2263) expr
ccgexprs.nim(2058) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2261) expr
ccgstmts.nim(513) genBlock
ccgexprs.nim(2263) expr
ccgexprs.nim(2058) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2263) expr
ccgexprs.nim(2047) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2263) expr
ccgexprs.nim(2058) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2264) expr
ccgstmts.nim(355) genIf
ccgexprs.nim(2263) expr
ccgexprs.nim(2058) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2263) expr
ccgexprs.nim(2058) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2263) expr
ccgexprs.nim(2058) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2263) expr
ccgexprs.nim(2047) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2285) expr
ccgstmts.nim(316) genVarStmt
ccgstmts.nim(306) genClosureVar
ccgstmts.nim(82) loadInto
ccgcalls.nim(559) genAsgnCall
ccgcalls.nim(195) genPrefixCall
cgen.nim(490) initLocExpr
ccgexprs.nim(2168) expr
cgen.nim(887) genProc
cgen.nim(852) genProcNoForward
cgen.nim(751) genProcAux
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2263) expr
ccgexprs.nim(2058) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2263) expr
ccgexprs.nim(2047) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2263) expr
ccgexprs.nim(2047) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2285) expr
ccgstmts.nim(316) genVarStmt
ccgstmts.nim(306) genClosureVar
ccgstmts.nim(93) loadInto
ccgexprs.nim(2262) expr
ccgexprs.nim(2054) genStmtListExpr
ccgexprs.nim(2281) expr
ccgexprs.nim(2001) genClosure
cgen.nim(490) initLocExpr
ccgexprs.nim(2168) expr
cgen.nim(887) genProc
cgen.nim(852) genProcNoForward
cgen.nim(751) genProcAux
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2284) expr
ccgstmts.nim(491) genWhileStmt
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2263) expr
ccgexprs.nim(2058) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2261) expr
ccgstmts.nim(513) genBlock
ccgexprs.nim(2263) expr
ccgexprs.nim(2058) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2263) expr
ccgexprs.nim(2047) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2263) expr
ccgexprs.nim(2058) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2263) expr
ccgexprs.nim(2058) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2263) expr
ccgexprs.nim(2058) genStmtList
ccgstmts.nim(1152) genStmts
ccgexprs.nim(2288) expr
ccgstmts.nim(778) genCase
ccgstmts.nim(752) genOrdinalCase
ccgstmts.nim(729) genCaseRange
ccgexprs.nim(83) genLiteral
ccgexprs.nim(34) genLiteral
msgs.nim(524) internalError
msgs.nim(495) liMessage
msgs.nim(324) handleError
msgs.nim(314) quit

fixed by split the '+','-' to two line :
`
var res = case line[0]

of '+': @[r.parseStatus(line)]

of '-': @[r.parseStatus(line)]

`

Calling `subscribe` breaks `quit`

Not sure how to title this, not even sure is it's a nim issue, async issue or redis lib issue, but the behaviour is that just by adding await redisClient.subscribe("whatever") you can make your code raise runtime exception.

import redis, asyncdispatch

proc asyncTest1() {.async.} =
    # A, B ... Error: unhandled exception: No handles or timers registered in dispatcher. [ValueError]
    echo "A"
    let redisClient = await openAsync()
    await redisClient.subscribe("command")
    echo "B"
    await redisClient.quit()
    echo "C" # never reached


proc asyncTest2() {.async.} =
    # runs OK: prints A B C
    echo "A"
    let redisClient = await openAsync()
    echo "B"
    await redisClient.quit()
    echo "C"


waitFor asyncTest1()

Error while compiling with threads: 'evalMessageIter' is not GC-safe as it calls 'keys'

Context:
compiling with latest nim version (1.7.1) and with the following:
nim c --run -d:ssl -d:release -mm:orc --threads:on Error.nim

and initially got this error:

'evalMessageIter' is not GC-safe as it calls 'keys'

I began tracing the problem one by one until I found the culprit for my particular program.

Error: 'readArrayLinesIter' is not GC-safe as it calls 'readNext'

I went to the lines where the proc is defined in three diferent places.
lines 262, 263 and 308 and added the {.gcsafe.} pragma to all and got the following:

Error: public implementation 'redis.readNext(r: AsyncRedis)' has non-public forward declaration at /home/.../.nimble/pkgs/redis-0.3.0/redis.nim(260, 6)

I added a * to proc readNext*(r: AsyncRedis): Future[RedisList] and got the following:

Error: public implementation 'redis.readNext(r: Redis)' has non-public forward declaration at /home/.../.nimble/pkgs/redis-0.3.0/redis.nim(259, 6)

So, also added another * to this proc readNext*(r: Redis): RedisList

The program finally compiled without issues and is working really well... so far. I'm still running tests to see how the program behaves, and perhaps someone else has run into this (maybe I'm doing something wrong?). I hope it helps.

PS thank you for taking the time to write this amazing code. it's beautiful

Example does not compile

See https://forum.nim-lang.org/t/4822

import redis, asyncdispatch

## Open a connection to Redis running on localhost on the default port (6379)
let redisClient = openAsync()

## Set the key `nim_redis:test` to the value `Hello, World`
await 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")

The example hasn't been changed since 2 years ago, was there an async/await refactor?

Can't compile Redis module

Hello,

trying to compile it gives following error:

redis.nim(269, 57) template/generic instantiation from here
redis.nim(278, 21) Error: invalid control flow: 'yield' within a constructor

RedisList should allow any redis objects including Arrays

RedisList should be a sequence of any redis objects including Arrays the same behavior as in redis-cli

In redis package: the defined types assumes RedisList can just be a seq[RedisString]

  RedisString* = string
    ## Bulk reply
  RedisList* = seq[RedisString]
    ## Multi-bulk reply

redis-cli parses nested arrays just fine

~ > redis-cli -h playground.hub.grid.tf  -p 9910                           
playground.hub.grid.tf:9910> SCAN
1) "\x10\x00\x00\xf04\x00\x00\r+\x00\x00\xaf\x97\xab\xff"
2)   1) 1) "\xe5\t\"\x1b\xc7\x88=.\xa8\x0e\x1a\xf2\x96\x84\xcb\xd5"
        2) (integer) 896
        3) (integer) 1534759473
     2) 1) "r\xac,^\xdc\x1cH\xe3\x06\x80\xe2\xf3k\xae:h"
        2) (integer) 364216
        3) (integer) 1534759473
     3) 1) "\xa3\xba\\\x04\xadU~To\x92\x10\xbdO\xfb\x8f\xfa"
        2) (integer) 402684
        3) (integer) 1534759473
     4) 1) "\x03Z\xc3\xedmf\xf64\x83\xbbg\x84Z\x17^\x8e"
        2) (integer) 75420
        3) (integer) 1534759473
     5) 1) "\x9cA\xbf\xba\xfa\xa2\n\xc7vz\xb0\xf0\x97\x89sc"
        2) (integer) 344
        3) (integer) 1534759473
....
....

nim v0.19 string nil issue

With nim v0.19.0:

โžœ  redis git:(master) nimble test
  Executing task test in /Users/user/Projects/nim/redis/redis.nimble
../src/redis.nim(149, 61) template/generic instantiation from here
../src/redis.nim(151, 12) Error: type mismatch: got <nil> but expected 'string'
stack trace: (most recent call last)
/Users/user/Projects/nim/redis/redis.nimble(18) testTask
/Users/user/.choosenim/toolchains/nim-0.19.0/lib/system/nimscript.nim(237) exec
/Users/user/.choosenim/toolchains/nim-0.19.0/lib/system/nimscript.nim(237, 7) Error: unhandled exception: FAILED: nim c -r tests/main.nim

My understanding is that this might already be addressed by PR #10

How to use hGetAll

If I populate with setk and then do let info = rds.get("somekey") this works ok.

But if these key is populated with hMSet (which works) and then I try to get data from with let info = rds.hGetAll("somekey") the whole thing fails with the following error.

Error: type mismatch: got <Prologue, string, proc (ctx: Context): Future[system.void]{.locks: <unknown>.}, seq[HttpMethod]>
but expected one of:
proc addRoute(app: Prologue; patterns: openArray[UrlPattern]; baseRoute = "";
              middlewares: Option[seq[HandlerAsync]] = none(seq[HandlerAsync]))
  first type mismatch at position: 2
  required type for patterns: openArray[UrlPattern]
  but expression '"/db/{databaseId}"' is of type: string
proc addRoute(app: Prologue; route: Regex; handler: HandlerAsync;
              httpMethod = HttpGet; middlewares: openArray[HandlerAsync] = @[])
  first type mismatch at position: 2
  required type for route: Regex
  but expression '"/db/{databaseId}"' is of type: string
proc addRoute(app: Prologue; route: Regex; handler: HandlerAsync;
              httpMethod: openArray[HttpMethod];
              middlewares: openArray[HandlerAsync] = @[])
  first type mismatch at position: 2
  required type for route: Regex
  but expression '"/db/{databaseId}"' is of type: string
proc addRoute(app: Prologue; route: string; handler: HandlerAsync;
              httpMethod = HttpGet; name = "";
              middlewares: openArray[HandlerAsync] = @[])
  first type mismatch at position: 3
  required type for handler: HandlerAsync
  but expression 'databaseInfo' is of type: proc (ctx: Context): Future[system.void]{.locks: <unknown>.}
  Pragma mismatch: got '{..}', but expected '{.gcsafe.}'.
  This expression is not GC-safe. Annotate the proc with {.gcsafe.} to get extended error information.
proc addRoute(app: Prologue; route: string; handler: HandlerAsync;
              httpMethod: openArray[HttpMethod]; name = "";
              middlewares: openArray[HandlerAsync] = @[])
  first type mismatch at position: 3
  required type for handler: HandlerAsync
  but expression 'databaseInfo' is of type: proc (ctx: Context): Future[system.void]{.locks: <unknown>.}
  Pragma mismatch: got '{..}', but expected '{.gcsafe.}'.
  This expression is not GC-safe. Annotate the proc with {.gcsafe.} to get extended error information.
1 other mismatching symbols have been suppressed; compile with --showAllMismatches:on to see them

expression: addRoute(app, "/db/{databaseId}", databaseInfo, @[HttpGet])

Set commands `SADD` and `SREM` accepting multiple `member` arguments

The set commands SADD and SREM accept multiple member arguments since Redis version 2.4; in nim's redis lib only the former is implemented via the sladd proc
https://github.com/nim-lang/redis/blob/master/src/redis.nim#L843

For adding multiple member support for both I can see two ways about it:

  1. Add an slrem proc next to the existing srem proc. This would be in line with the existing library, but creates another non-obvious function.
  2. Change both sadd and srem to support both a string and seq[string] as members argument; deprecating / removing sladd.

What would be the preferred approach?

How to get rid of Error: 'spawn' takes a GC safe call expression with the redis client

@Araq

This doesn't work:

import  os, times, posix, logging, redis, threadpool

{.experimental.}

var running = true

proc proc_spawned()  =
  let redis_con = redis.open()
  defer: redis_con.quit

  while running == true:
    echo("bRPop")
    discard redis_con.bRPop("test", 1000)
    os.sleep(1000)

spawn proc_spawned()

The problem i identified, happens with Redis.bRPop proc, but doesn't happen with Redis.rPop proc.

proc bRPop*(r: Redis, keys: varargs[string], timeout: int): RedisList =
  ## Remove and get the *last* element in a list, or block until one
  ## is available.
  var args: seq[string] = @[]
  for i in items(keys): args.add(i)
  args.add($timeout)
  r.sendCommand("BRPOP", args)
  return r.readArray()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.