Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to assign file as a value to a key and check size/length of any value #220

Open
jubins opened this issue Sep 13, 2018 · 1 comment

Comments

@jubins
Copy link

jubins commented Sep 13, 2018

I am trying to do two things:

  1. Simple set operations, where I want to set key and value as a text file. For example my key:A100 and its value:A100.obj or A100.txt.
  2. Get that value from redis server and check size of the value.
    Below is my code (basically I am trying to use redis as a simple database where my files are associated with unique keys and I could access them using the get method).
CODE:

    val host = "localhost"
    val port = 6379
    val file = "A100.obj"

    var key1 = "A100"
    val value1 = file //seems this is taking the filename as string (not the file itself)

    try {
      var r = new RedisClient(host, port)
      r.set(key1, value1)
      println(r.get(key1))
      println(r.strlen(key1))
    }catch{
      case err: Exception => println("Exception: ", err)
    }
OUTPUT:
   Some(A100.obj)
   Some(8)

Any help on this is appreciated and let me know if I could provide any additional information for this. Thank you.

@debasishg
Copy link
Owner

I am not sure I understand what you are trying to do here. When u do val value1 = file do you expect to assign the contents of the file to value1. This is not going to happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants