Apply cache to cms client
This commit is contained in:
parent
9acec8bbe2
commit
ea91a6043e
3 changed files with 24 additions and 4 deletions
1
qlfile
1
qlfile
|
@ -8,3 +8,4 @@ ql cl-dotenv
|
||||||
ql clack-errors
|
ql clack-errors
|
||||||
git microcms https://github.com/skyizwhite/microcms-lisp-sdk
|
git microcms https://github.com/skyizwhite/microcms-lisp-sdk
|
||||||
ql local-time
|
ql local-time
|
||||||
|
ql function-cache
|
||||||
|
|
|
@ -42,3 +42,7 @@
|
||||||
(:class qlot/source/ql:source-ql
|
(:class qlot/source/ql:source-ql
|
||||||
:initargs (:%version :latest)
|
:initargs (:%version :latest)
|
||||||
:version "ql-2024-10-12"))
|
:version "ql-2024-10-12"))
|
||||||
|
("function-cache" .
|
||||||
|
(:class qlot/source/ql:source-ql
|
||||||
|
:initargs (:%version :latest)
|
||||||
|
:version "ql-2023-10-21"))
|
||||||
|
|
|
@ -3,18 +3,33 @@
|
||||||
(:import-from #:microcms
|
(:import-from #:microcms
|
||||||
#:define-list-client
|
#:define-list-client
|
||||||
#:define-object-client)
|
#:define-object-client)
|
||||||
|
(:import-from #:function-cache
|
||||||
|
#:defcached)
|
||||||
(:import-from #:website/lib/env
|
(:import-from #:website/lib/env
|
||||||
#:microcms-service-domain
|
#:microcms-service-domain
|
||||||
#:microcms-api-key)
|
#:microcms-api-key)
|
||||||
(:export #:get-blog-list
|
(:export #:get-about
|
||||||
#:get-blog-detail
|
#:get-work
|
||||||
#:get-about
|
#:get-blog-list
|
||||||
#:get-work))
|
#:get-blog-detail))
|
||||||
(in-package #:website/lib/cms)
|
(in-package #:website/lib/cms)
|
||||||
|
|
||||||
(setf microcms:*service-domain* (microcms-service-domain))
|
(setf microcms:*service-domain* (microcms-service-domain))
|
||||||
(setf microcms:*api-key* (microcms-api-key))
|
(setf microcms:*api-key* (microcms-api-key))
|
||||||
|
|
||||||
|
(defmacro memorize (name timeout)
|
||||||
|
(let ((origin (gensym)))
|
||||||
|
`(progn
|
||||||
|
(setf (fdefinition ',origin) (fdefinition ',name))
|
||||||
|
(defcached (,name :timeout ,timeout) (&key query)
|
||||||
|
(,origin :query query)))))
|
||||||
|
|
||||||
(define-object-client about)
|
(define-object-client about)
|
||||||
|
(memorize get-about 60)
|
||||||
|
|
||||||
(define-object-client work)
|
(define-object-client work)
|
||||||
|
(memorize get-work 60)
|
||||||
|
|
||||||
(define-list-client blog)
|
(define-list-client blog)
|
||||||
|
(memorize get-blog-list 60)
|
||||||
|
(memorize get-blog-detail 60)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue