Skip to content
  • totten's avatar
    (#174) Memcache(d) - Updates to comply with PSR-16 · fbbfd6dd
    totten authored
    There are two drivers, `CRM_Utils_Memcache` and `CRM_Utils_Memcached`.  It's
    nice to update them in tandem (with similar design decisions).  If an admin
    admin is experimenting/debugging, this consistency makes it easier to switch
    between drivers.  (Cache data written by one driver can be read by the other
    driver.)
    
    In addition to the standard PSR-16-style changes, there are a couple changes
    in how data is formatted when written to memcache:
    
    * To allow support for targetted `flush()`ing (one prefix at a time), we update
      the naming convention per https://github.com/memcached/memcached/wiki/ProgrammingTricks#deleting-by-namespace
      This means that a typical key includes a bucket-revision code:
        * BEFORE: `<site-prefix>/<bucket-prefix>/<item-key>` (`dmaster/default/mykey`)
        * AFTER: `<site-prefix>/<bucket-prefix>/<bucket-revision>/<item-key>` (`dmaster/default/5b33011fea555/mykey`)
    * Values are `serialize()`d. This resolves an ambiguity where `Memcache::get()`
      does not let us know if it returns `FALSE` because there's an error because
      that's the stored value. By serializing, those scenarios can be distinguished.
        * `get(...) === FALSE` means "item was not found"
        * `get(...) === serialize(FALSE)` means "item was found with value FALSE"
    fbbfd6dd