定制 mauretto78/in-memory-list-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mauretto78/in-memory-list-bundle

Composer 安装命令:

composer require mauretto78/in-memory-list-bundle

包简介

PHP Bundle

README 文档

README

SensioLabsInsight Codacy Badge license Packagist

This is the official Symfony bundle for In-Memory List package.

Install Guide

Step 1: Include In-Memory List Bundle in your project with composer:

composer require mauretto78/in-memory-list-bundle

Step 2: Setup your config.yml to configure your driver and connection parameters

Here is an example:

# In Memory List
in_memory_list:
    driver: 'redis'
    parameters:
        scheme: 'tcp'
        host: '127.0.0.1'
        port: '6379'
        options:
          profile: '3.2'

Please refer to In-Memory List page for more details.

Step 3: Setup your AppKernel.php by adding the InMemoryList Bundle

// ..
$bundles[] = new InMemoryList\Bundle\InMemoryListBundle();

Step 4: Setup yor routing_dev.yml

Add these lines at the bottom of your routing_dev.yml file:

_inmemorylist:
    resource: '@InMemoryListBundle/Resources/config/routing.yml'

Usage Guide

Caching data in your controller:

public function indexAction(Request $request)
{
    $simpleArray = json_encode([
        [
            'userId' => 1,
            'id' => 1,
            'title' => 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit',
            'body' => "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto",
        ],
        [
            'userId' => 1,
            'id' => 2,
            'title' => 'qui est esse',
            'body' => "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla",
        ],
    ]);

    /** @var Cache $cache */
    $cache = $this->container->get('in_memory_list');
    $cachedList = $cache->getClient()->create(json_decode($simpleArray), ['uuid' => 'simple-list', 'ttl' => 1000]);

    // replace this example code with whatever you need
    return $this->render('default/index.html.twig', [
        'cachedList' => $cachedList,
        'base_dir' => realpath($this->getParameter('kernel.project_dir')).DIRECTORY_SEPARATOR,
    ]);
}

Now you can loop data in your twig files:

{% for item in cachedList %}
    <li>{{ item.userId }}</li>
    <li>{{ item.id }}</li>
    <li>{{ item.title }}</li>
    <li>{{ item.body }}</li>
{% endfor %}

Symfony Profiler

You can manage cached lists through the Symfony Profiler:

Symfony Profiler

Support

If you found an issue or had an idea please refer to this section.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

统计信息

  • 总下载量: 37
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-06-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固