Code Monkey home page Code Monkey logo

rah_memcached's Introduction

rah_memcached

Download | Packagist | Issues

A plugin for Textpattern CMS that stores parts of your templates in Memcached, a distributed in-memory key-value caching system.

Install

Using Composer:

$ composer require rah/rah_memcached

Or download an installer package.

Basics

The plugin, rah_memcached, introduces a new container tag to Textpattern’s arsenal. The tag stores the wrapped content, and variables set within it, in Memcached’s in-memory storage.

<rah::memcached>
    <txp:variable name="variable1" value="value" />
    <txp:article_custom limit="200">
        <txp:title />
    </txp:article_custom>
</rah::memcached>

On subsequent calls the resulting output markup and variables will be loaded from memory, skipping template parsing and code execution, speeding up your site and alleviating database load.

Requirements

Configuration

Connected server can be configured through Textpattern’s textpattern/config.php file:

define('RAH_MEMCACHED_HOST', 'localhost');
define('RAH_MEMCACHED_PORT', 11211);

Attributes

<rah::memcached>
    ...contained statement...
</rah::memcached>

The tag is a container and attributes for it follow.

name
Sets a name, a key, for the cached item. The given name is used identify the item, and save and fetch it from the storage. If a name is not defined, it’s automatically created by hashing the given contained markup. While the name is optional, giving it is more efficient and avoids any potential hash collisions.
Default: undefined Example: name="mykey"

expires
Time in seconds it takes to the stored item to expire and be refreshed. If zero (0), the cache is kept in memory until the cache is flushed or Memcached is restarted.
Default: 0 Example: expires="3600"

persist
If enabled, ignores content updates as set by site’s lastmod timestamp. By default, the cache is invalidated when Texptatern’s lastmod timestamp is updated, which is done when any content is updated.
Default: disabled Example: persist

Examples

Store section navigation in memory

<rah::memcached name="navigation">
    <txp:section_list wraptag="ul" break="li">
        <txp:section />
    </txp:section_list>
</rah::memcached>

Store variables in memory

<rah::memcached>
    <txp:variable name="color" value="red" />
    <txp:variable name="size" value="small" />
</rah::memcached>

Color: <txp:variable name="color" />
Size: <txp:variable name="size" />

Changelog

Version 0.3.0 – 2022/04/22

  • Fixes PHP >= 8.1 compatibility.
  • Now requires PHP >= 8.1.

Version 0.2.0 – 2022/04/17

  • Register the tag for Textpattern >= 4.7.0 compatibility.
  • Replaced lastmod attribute with persist.
  • Now requires PHP >= 7.2.0.
  • Now requires Textpattern >= 4.7.0.

Version 0.1.0 – 2014/03/19

  • Initial release.

rah_memcached's People

Contributors

gocom avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mst-textpattern

rah_memcached's Issues

questions about rah_memcached

(Yeah, I know, the subject for this issue sucks!)

Hi, gocom.
I've just found this new rah thing. Looks nice!
I've yet to install it and give it a try. In the meanwhile, I've a few questions:

  1. Does this plugin provide a similar functionality to aks_cache? It seems so, but I've to ask.

  2. I see the plugin provides some cache flushing mechanism on content updates. Does it also provide any mechanism (a GUI?) to flush the cache "manually"?

  3. Tangentially related: what about rah_cache? Is it still under ongoing development (seems not) or should I forget about it? (I've installed it on a project but never found the time to configure and test it properly).

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.