Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6717063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:48:28+00:00 2026-05-26T08:48:28+00:00

I need to have library that can be used as memcache with my codeigniter.

  • 0

I need to have library that can be used as memcache with my codeigniter. what I need to do is to extract menus from DB on user’s role basis and then store the menu in cache. The idea is to show the exact menu to another user if it has the same role(without calling DB). I have a separate view for menus(Header) and includes it on each of my page(view). Here a thing to note is every time a controller is executed when requesting to a new page(view).

I just used a library https://github.com/tomschlick/memcached-library which did not work for me in this scenario. As I call the new page the header view throws an error for not defined get function for memcache (as I am getting data in header through memcache).

Is there any solid library or way to accomplish the task?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:48:29+00:00Added an answer on May 26, 2026 at 8:48 am

    CodeIgniter2 has caching library, which supports Memcache https://www.codeigniter.com/user_guide/libraries/caching.html#memcached-caching

    Use something lilke that:

    $role_id = 2;  
    $menu = $foo = $this->cache->get('menu_'.$role_id);
    if (!$menu){
      $menu_data = $this->my_model->loadMenu($role_id);
      $menu = $this->load->view('menu_tpl', $menu_data, TRUE);
      $this->cache->save('menu_'.$role_id, $menu);
    }
    

    Sample memcache.php from the CI forum

    <?php
      if (!defined('BASEPATH')) exit('No direct script access allowed');
    
      $config['memcached'] = array(
              'hostname' => '127.0.0.1',
              'port'        => 11211,
              'weight'    => 1
      );
    ?> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a need to create a library of Object Oriented PHP code that
In some library code, I have a List that can contain 50,000 items or
We have a project that generates a code snippet that can be used on
Can anyone point to libraries that can be used for Printing from Compact .Net
I have a OCaml library with lots of classes I need some translator to
I have developed a simple library in Ruby and need to use this in
I have downloaded a third party library and they have classes I need to
I have a project in my IDE. I need to make a shared library
I have need to select a number of 'master' rows from a table, also
I have need to return multiple results from a subquery and have been unable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.