V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
lml12377
V2EX  ›  PHP

关于 PSR-6 和 PSR-16 的问题

  •  
  •   lml12377 · 2017-05-31 16:01:40 +08:00 · 2581 次点击
    这是一个创建于 2537 天前的主题,其中的信息可能已经有所发展或是发生改变。

    既然 PSR-6 早早的被 accepted 之后,为什么还要通过 PSR-16 ?既然通过了 16 这种更 "Simple" 的缓存操作途径,为啥不把 PSR-6 废弃掉。。。

    PSR: http://www.php-fig.org/psr/

    Symfony Cache 实现: https://github.com/symfony/cache

    Symfony PSR-6 和 PSR-16 互转: https://symfony.com/doc/current/components/cache/psr6_psr16_adapters.html

    其实我个人感觉把单条记录抽象为 Item 也是件不错的事情,可以针对这个对象做一些事情,比如 get() 在获取到值之后 return 之前,可以 trigger Event 来做一些 filter 操作等等。

    所以,我们在实现的时候是都实现,还是有针对性的选择一项实现?

    10 条回复    2017-06-01 17:11:19 +08:00
    tabris17
        1
    tabris17  
       2017-05-31 16:03:29 +08:00   ❤️ 1
    抽象出一个 Item 对象操作起来多一步,不方便呗
    lml12377
        2
    lml12377  
    OP
       2017-05-31 16:07:11 +08:00
    @tabris17 只是感觉 fig 作为标准组织,本来就是来做制定标准和“统一”这件事情的,虽然我们应该包容多元,这一个 Cache 分两个标准总感觉路子有点野。。。
    minbaby
        3
    minbaby  
       2017-05-31 16:27:07 +08:00   ❤️ 1
    讲道理 psr-6 更 oo 一点,psr-16 更 php 一点
    lml12377
        4
    lml12377  
    OP
       2017-05-31 16:42:32 +08:00
    @minbaby 确实~
    jhdxr
        5
    jhdxr  
       2017-05-31 17:04:32 +08:00   ❤️ 1
    psr 6 定的太细了,库实现的时候几乎没什么自己发挥的余地,而且有些场景并不需要那么高要求的 cache。话说我记得当年因为这个,php-fig 还退了一批人来着。。。
    lml12377
        6
    lml12377  
    OP
       2017-05-31 17:47:43 +08:00
    @jhdxr 这段历史还真不知道。。
    cxbig
        7
    cxbig  
       2017-05-31 21:42:54 +08:00   ❤️ 1
    也许 Deprecated 只是时间问题,就像 PSR-0 一样。
    lml12377
        8
    lml12377  
    OP
       2017-06-01 15:32:56 +08:00
    @cxbig 说不定真有可能
    cxbig
        9
    cxbig  
       2017-06-01 16:49:40 +08:00   ❤️ 1
    @lml12377 可能不会被干掉,我问过一个大佬,这两个应该会并存,一个是复杂的实现,一个是简易实现。
    他的回复如下:
    PSR-6 solves this problem already, but in a rather formal and verbose way for what the most simple use cases need. This simpler approach aims to build a standardized streamlined interface for common cases. It is independent of PSR-6 but has been designed to make compatibility with PSR-6 as straightforward as possible.
    lml12377
        10
    lml12377  
    OP
       2017-06-01 17:11:19 +08:00
    @cxbig 嗯,这段话在 PSR-16 的 Introduction 也写了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2652 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 05:06 · PVG 13:06 · LAX 22:06 · JFK 01:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.