Log in

hypeStash

Photo by   frank mckennaUnsplash
    hypeJunction

    hypeStash

    Elgg 3.0

    API for caching common entity data to reduce DB queries

    • Caches entity likes count
    • Caches entity comments count
    • Caches last comment
    • Caches user friends count
    • Caches group members count

    Developer Notes

    Logic

    The plugin uses preloader classes to load values from the database on first request. The value is cached and returned on consequent calls. Preloader::up() can be used to define when the cached value should be reset. For example, the value of likes is constant until a new like annotation is created, or an old is deleted, so we register our reset function for those events.

    Helpers

    You can use helper functions to retrieve counts using caching framework. All available shortcut functions can be found in /lib/functions.php

    elgg_get_total_likes($entity);
    elgg_get_total_comments($entity);
    // etc.
    

    Custom Properties

    $stash = \hypeJunction\Stash\Stash::instance();
    
    // Register a new cacheable property
    $stash->register(new CustomProperty()); // Custom property must implement Preloader interface
    
    // Get property value
    $prop = $stash->get(CustomProperty::PROPERTY, $entity);
    

    Package Releases

    VersionRelease Date
    hypeStash 1.0.21.0.2
    hypeStash 1.0.11.0.1

    Changelog

    1.0.1 (2018-06-29)

    1.0.0 (2018-06-29)

    Features

    • releases: initial commit (ee0c8c2)

    About

    Dependencies

    Requires
    Elgg version >= 3.0