Redis

Cancel an already executing task in Python RQ?

Deadly 提交于 2021-02-08 12:45:55
问题 I am using http://python-rq.org/ to queue and execute tasks on Heroku worker dynos. These are long-running tasks and occasionally I need to cancel them in mid-execution. How do I do that from Python? from redis import Redis from rq import Queue from my_module import count_words_at_url q = Queue(connection=Redis()) result = q.enqueue( count_words_at_url, 'http://nvie.com') and later in a separate process I want to do: from redis import Redis from rq import Queue from my_module import count

Cancel an already executing task in Python RQ?

大憨熊 提交于 2021-02-08 12:45:47
问题 I am using http://python-rq.org/ to queue and execute tasks on Heroku worker dynos. These are long-running tasks and occasionally I need to cancel them in mid-execution. How do I do that from Python? from redis import Redis from rq import Queue from my_module import count_words_at_url q = Queue(connection=Redis()) result = q.enqueue( count_words_at_url, 'http://nvie.com') and later in a separate process I want to do: from redis import Redis from rq import Queue from my_module import count

Cancel an already executing task in Python RQ?

狂风中的少年 提交于 2021-02-08 12:45:01
问题 I am using http://python-rq.org/ to queue and execute tasks on Heroku worker dynos. These are long-running tasks and occasionally I need to cancel them in mid-execution. How do I do that from Python? from redis import Redis from rq import Queue from my_module import count_words_at_url q = Queue(connection=Redis()) result = q.enqueue( count_words_at_url, 'http://nvie.com') and later in a separate process I want to do: from redis import Redis from rq import Queue from my_module import count

Node.js & Redis / hget synchronize

旧街凉风 提交于 2021-02-08 10:32:24
问题 I wish to create a synchronize command of hget in node.js. I wrote the following: var db = require("redis"); var dbclient = db.createClient(); var res1 = dbclient.hget("all_records", "/" + full_path) if (res1 != undefined){ objStatus.status = "TRUE" } else { objStatus.status = "FALSE" } The problem is that in res1 , I always gets true , while I set numbers to this field: dbclient.hset("all_records", key, size); // size is number It also returns true if the key doesn't exists. How can I

Node.js & Redis / hget synchronize

不打扰是莪最后的温柔 提交于 2021-02-08 10:31:34
问题 I wish to create a synchronize command of hget in node.js. I wrote the following: var db = require("redis"); var dbclient = db.createClient(); var res1 = dbclient.hget("all_records", "/" + full_path) if (res1 != undefined){ objStatus.status = "TRUE" } else { objStatus.status = "FALSE" } The problem is that in res1 , I always gets true , while I set numbers to this field: dbclient.hset("all_records", key, size); // size is number It also returns true if the key doesn't exists. How can I

Redis list of nested keys

Deadly 提交于 2021-02-08 07:29:17
问题 I have saved lists in following format in my Redis database. key:inner-key1:inner-key2:inner-key3 For example my database looks like this: A:B:X:val1 A:B:Y:val2 A:C:X:val3 A:C:Y:val4 How can I get inner keys for key B? I was trying to get it using KEYS A:B:*, but result of this are whole lines "A:B:X:val1" and "A:B:X:val2". All I need is to get only first inner key of "A:B" in format for example [X, Y]. 回答1: You can use Redis Hash to acheive the same: Your Keys are A:B:X:val1 A:B:Y:val2 A:C:X

Redis list of nested keys

霸气de小男生 提交于 2021-02-08 07:27:33
问题 I have saved lists in following format in my Redis database. key:inner-key1:inner-key2:inner-key3 For example my database looks like this: A:B:X:val1 A:B:Y:val2 A:C:X:val3 A:C:Y:val4 How can I get inner keys for key B? I was trying to get it using KEYS A:B:*, but result of this are whole lines "A:B:X:val1" and "A:B:X:val2". All I need is to get only first inner key of "A:B" in format for example [X, Y]. 回答1: You can use Redis Hash to acheive the same: Your Keys are A:B:X:val1 A:B:Y:val2 A:C:X

【面经】离职10天,面了4家公司,我的感受...

為{幸葍}努か 提交于 2021-02-08 06:39:46
http://dy.163.com/v2/article/detail/F75J5CHO0511Q1AF.html    20 大进阶架构专题每日送达      作者:莫那鲁道   来源:http://1t.click/U4g   楼主离职已有 10 天,这段时间里除了看源码,就是投简历面试了。一共面试了 4 家,说说感受。    XX 汇   XX 汇是一家小型的电商网站,由于楼主的技术栈集中在 Java 语言这里,所以,即使楼主对并发,JVM,Netty,Spring 等都稍有了解,但依然没有任何优势—— 因为他们完全用不到。   整个面试过程中,问了大概以下问题:   1.说说你的项目,用了 SpringCloud 哪些功能?   2.熟悉 Mysql 吗?说说索引(不懂 Mysql 啊大佬)   3.如何实现一个单例模式(这个俺擅长)   4.平时使用了哪些线程池(这个俺也擅长)   5.Map 接口有哪些类(这个俺也擅长)   6.写一段 SQL 呗(不会 SQL)   7.如何实现免登陆功能(cookie session?)   当然,被刷了,估计是 SQL 不够好吧,而我擅长的他们也不需要。    XX 旅游   这个就比较奇葩了,是最奇葩的一个,面试官是个小伙子,根本不懂并发,然后强行问我并发,自己基本一言不发。还对我的回答貌似不满意?   1.自我介绍一下。  

Scrapy-redis 分布式爬虫

落爺英雄遲暮 提交于 2021-02-08 05:31:44
###Scrapy-redis 分布式爬虫 Scrapy 是一个通用的爬虫框架,但是不支持分布式,Scrapy-redis是为了更方便地实现Scrapy分布式爬取,而提供了一些以redis为基础的组件。scrapy-redis 的解决是把这个Scrapy queue换成redis数据库(也是指redis队列),从同一个redis-server存放要爬取的request,便能让多个spider去同一个数据库里读取。 ###Scrapy-Redis分布式策略: Master端(核心服务器) :搭建一个Redis数据库,不负责爬取,只负责url指纹判重、Request的分配,以及数据的存储; Slaver端(爬虫程序执行端) :负责执行爬虫程序,运行过程中提交新的Request给Master 首先Slaver端从Master端拿任务(Request、url)进行数据抓取,Slaver抓取数据的同时,产生新任务的Request便提交给 Master 处理; Master端只有一个Redis数据库,负责将未处理的Request去重和任务分配,将处理后的Request加入待爬队列,并且存储爬取的数据。 ####Master 安装Redis 1.下载及安装 wget http://download.redis.io/releases/redis-3.2.6.tar.gz tar xzf

How to do HSET only if key exists with Redis?

依然范特西╮ 提交于 2021-02-08 04:22:12
问题 I want to run a HSET command but only if the key exists. Similar to HSETNX except exists instead of not exists I've read about maybe using WATCH or something but so far I can't really figure it out. I would appreciate a nudge in the right direction. The only thing I see is this but I don't see how this works considering these aren't even valid redis commands. HSET if key exist Also, after reading about WATCH that concerns me because I don't want to abort the transaction if another request