22 Matching Annotations
  1. Aug 2022
  2. Jul 2022
    1. 运行CLI不需要任何特殊操作-无需任何参数即可启动它,即可处于交互模式下: $ redis-cli 127.0.0.1:6379> ping PONG

      redis-cli

  3. May 2022
  4. Apr 2022
    1. 以为集合(Set)类型里面的元素总是无序排列的,其实不是的,在特定情况下,它也可以做到有序排列。 在redis里,集合的编码有两种,intset(整数集合)或者hashtable(哈希表)。intset编码的集合里面的元素是有序的(按照整数从小到大排列),hashtable编码的集合是无序的。 当集合同时满足下面两个条件时,会使用intset编码: 保存的所有元素都是整数元素数量不超过512个(这个值可以通过配置文件里的set-max-intset-entries进行调整) 要注意的是,一个使用intset编码的集合,当上述两个条件不能同时满足时,redis就会将集合的编码由intset改为hashtable。

      redis 集合(Set)的排序问题

      集合的编码有 inset(整数集合)、hashtable(哈希表)。

      intset 编码的集合内元素是有序的,按整数从小到大排列。

      hashtable 编码的集合是无序的。

      集合满足 2 个条件,会使用 intset 编码: 1> 所有元素是整数; 2> 元素数量 <= 512 个; (数量,可在配置文件 set-max-intset-entries 设置)

      不满足以上两个条件,redis 会将集合的编码由 intset 改为 hashtable。

    1. SETEX key seconds value

      Set key to hold the string value and set key to timeout after a given number of seconds.

      This command is equivalent to executing the following commands:

      SET mykey value EXPIRE mykey seconds

  5. Jun 2021
  6. Jul 2020
  7. Apr 2020
    1. def handle_exception(self, job, *exc_info):

      To unit test an exception handler:

      worker = Worker(..., exception_handler=[handle_exception])
      try:
          raise Exception()
      except Exception:
          exc_info = sys.exc_info()
      
      worker.handle_exception(job, *exc_info)
      
    1. failure_ttl

      How long to keep a failed job.

    2. result_ttl=600

      How long to keep a successful job.

    3. job.meta['handled_by'] = socket.gethostname() job.save_meta()

      You can add metadata on the job like keeping track of the number of times a job has been retried for example.

    1. w = Worker([q], exception_handlers=[foo_handler, bar_handler])

      Exception handlers are attached to the worker.

    2. def my_handler(job, exc_type, exc_value, traceback): # do custom things here

      Write an exception handler that requeues a failed job.

  8. Jan 2020
    1. But the reason is that, if your host system does not have the vm.overcommit_memory=1 enabled, you will not be able to switch it inside container.

      Fixed redis issue on harbor: "Can't save in background: fork: Cannot allocate memory"

      Added on /root/harbor/docker-compose.yml:

      command: sh -c 'echo 1 > /proc/sys/vm/overcommit_memory'

      Also executed command: sh -c 'echo 1 > /proc/sys/vm/overcommit_memory' on the main server harbor (not only on the container)

  9. Aug 2019
  10. Nov 2018
  11. Dec 2017
  12. Jul 2017
    1. since lua-resty-redis can not be used in set_by_lua*, dynamic routing based on redis should be impelemented in the access_by_lua block

  13. Oct 2014
    1. This in turn means that Redis Cluster does not have to take meta data in the data structures in order to attempt a value merge, and that the fancy commands and data structures supported by Redis are also supported by Redis Cluster. So no additional memory overhead, no API limits, no limits in the amount of elements a value can contain, but less safety during partitions.

      A solid trade-off, I think, and says a lot about the intended use cases.