forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
441 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
* Redis Incr 怎么设置过期时间 | ||
|
||
Redis 的 =INCR= 命令只能增加一个 Key 对应的值,而不能设置过期时间。如果需要一个具有过期时间的计数器,可以使用 =SETEX= 命令来设置一个带过期时间的 Key,然后结合 =INCR= 命令来实现计数器功能,例如: | ||
|
||
#+begin_src | ||
SETEX my_counter 3600 0 # 有效期为 1 小时,计数器初始值为 0 | ||
#+end_src | ||
|
||
每次需要增加计数器的值时,可以使用 INCR 命令: | ||
|
||
#+begin_src | ||
INCR my_counter | ||
#+end_src | ||
|
||
注意,设置的时间单位为秒,如果需要设置其他时间单位,可以使用多个参数,例如: | ||
|
||
#+begin_src | ||
SETEX my_counter 60m 0 # 有效期为 60 分钟,计数器初始值为 0 | ||
#+end_src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,45 @@ | ||
;;; init-copilot-local --- Support copilot | ||
;;; init-copilot-local.el --- Support copilot | ||
;;; Commentary: | ||
;;; Code: | ||
|
||
(add-to-list 'load-path | ||
(expand-file-name (concat user-emacs-directory "lisp/copilot.el"))) | ||
(expand-file-name (concat user-emacs-directory "lisp/copilot.el"))) | ||
(require 'copilot) | ||
;; copilot automatically provide completions | ||
|
||
;; Copilot automatically provide completions | ||
(add-hook 'prog-mode-hook 'copilot-mode) | ||
|
||
; complete by copilot first, then auto-complete | ||
;; Complete by copilot first, then auto-complete | ||
(defun my-tab () | ||
(interactive) | ||
(or (copilot-accept-completion) | ||
(ac-expand nil))) | ||
|
||
(with-eval-after-load 'auto-complete | ||
; disable inline preview | ||
;; Disable inline preview | ||
(setq ac-disable-inline t) | ||
; show menu if have only one candidate | ||
;; Show menu if have only one candidate | ||
(setq ac-candidate-menu-min 0)) | ||
|
||
|
||
(setq copilot-max-characters 1000000) ;; 增大为 1,000,000 | ||
|
||
(define-key copilot-completion-map (kbd "<tab>") 'copilot-accept-completion) | ||
(define-key copilot-completion-map (kbd "TAB") 'copilot-accept-completion) | ||
|
||
;; Bind `my-tab` function to TAB key in prog-mode | ||
(add-hook 'prog-mode-hook | ||
(lambda () | ||
(local-set-key (kbd "TAB") 'my-tab) | ||
(local-set-key (kbd "<tab>") 'my-tab))) | ||
|
||
(defun maybe-disable-copilot () | ||
"Disable Copilot if the buffer is too large." | ||
(when (> (buffer-size) copilot-max-characters) | ||
(copilot-mode -1) | ||
(message "Copilot disabled due to large buffer size."))) | ||
|
||
(add-hook 'copilot-mode-hook 'maybe-disable-copilot) | ||
|
||
|
||
(provide 'init-copilot-local) | ||
;;; init-copilot-local.el ends here |
Oops, something went wrong.