V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
yagamil

gin 有没有类似 flask, django 这种缓存装饰器这样用法的?

  •  
  •   yagamil · Jun 18, 2022 · 1980 views
    This topic created in 1416 days ago, the information mentioned may be changed or developed.

    python 下的 flask django 使用中间件 cache ,可以方便地使用 redis 缓存。 gin 下不知道有没有类似的用法。 没有的话,只能 json 序列化,从 redis 里面取了

    fityme
        1
    fityme  
       Jun 18, 2022
    go 的中间件不都是这么实现的。只是没有对应的语法糖而已
    cheng6563
        2
    cheng6563  
       Jun 19, 2022
    go 的反射做不带这些东西,类似场景 go 要么硬编码要么代码生成。
    janxin
        3
    janxin  
       Jun 19, 2022
    没有语法糖实现装饰器

    如果是缓存返回结果可以使用中间件
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2520 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 01:43 · PVG 09:43 · LAX 18:43 · JFK 21:43
    ♥ Do have faith in what you're doing.