English 中文(简体)
与JSON的Combine Redis-Python管道
原标题:Combine Redis-Python pipeline with JSON
The bounty expires in 5 days. Answers to this question are eligible for a +500 reputation bounty. NedStarkOfWinterfell is looking for an answer from a reputable source.

Redis提供了一种途径,以输入结构化的JSON文件,并以内容检索这些文件(例如,这可以提供自动检索经验)。 因此,我正在这样做。

test = "{ key :  glooler-61245 ,  val :  sighgh }"
r.json().set("a:glooler-61245", Path.root_path(), ast.literal_eval(test))
rs.search(Query(f"glooler"))

Redis还提供管道,使许多插入能够一起进行,并在一大批中执行,例如:

pipe = r.pipeline()
pipe.set("a", "a value")
pipe.set("b", "b value")
pipe.execute()
pipe.get("a")

然而,管道只允许用户按照钥匙检索,而与JSON不同,后者可以通过内容检索。 我怎么能够把这二人混在一起,以便我能够把10k结构化的初等人物推向第一例,然后在一行中铺设管道,然后能够以价值取回?

我试图这样做:

pipe.set( a:glooler-61246 , "{ key :  glooler-61246 ,  val :  loltest }")
pipe.set( a:glooler-61247 , "{ key :  glooler-61247 ,  val :  loltest2 }")
pipe.set( a:glooler-61248 , "{ key :  glooler-61248 ,  val :  loltest3 }")
pipe.set( a:glooler-61249 , "{ key :  glooler-61249 ,  val :  loltest4 }")
pipe.execute()

然而,rs.search(Query(f"glooler”)仍然只回到我先前插入的第一个数值。

问题回答

我再次审视了你的问题,是否只是要重新讨论关键和价值? 我刚刚读到文件。

难道你会把他们像现在这样吗?

pipe.set( glooler-61246 ,  loltest )
pipe.set( glooler-61247 ,  loltest2 )
pipe.set( glooler-61248 ,  loltest3 )
pipe.set( glooler-61249 ,  loltest4 )

pipe.execute()

为什么你们需要将冰川价值储存在关键和价值上?





相关问题
How do you mix SQL DB vs. Key-Value store (i.e. Redis)

I m reviewing my code and realize I spend a tremendous amount of time taking rows from a database, formatting as XML, AJAX GET to browser, and then converting back into a hashed javascript object ...

Predis sharding (consistent hashing)

Predis claim to have Client-side sharding (support for consistent hashing of keys). http://github.com/nrk/predis I can do sharding using connect to an array of profiles (nodes) but it isn t ...

key value stores for extendable objects

http://www.infoq.com/presentations/newport-evolving-key-value-programming-model is a video about KV stores, and the whole premise is that redis promotes a column-based style for storing the attributes ...

nginx/redis and handling tracking params in url

I am using nginx and redis in my website. For several items on my site, I want to add tracking params to their urls so that when a user clicks on an item, I can collect statistics of user usage apart ...

热门标签