Jump to content

How to flush Memcached using cronjob


Recommended Posts

Hi, 

 

I'm a merchant with very little knowledge on php commands.

I have memcahed installed on my server and it works good, problem is the allocated memory of 16mb gets consumed very fast above 100% usage.

I contacted hosting and the only provided blogs of how to create command line and cronjob to flush Memcached.

Unfortunately not knowing anything about commands, I guessed I might be getting a solution from somebody here.

Can anyone teach me how to go about commands? or better still, can somebody provide me with the cron url if thats what is only needed.

In my advanced parameters the memcache is set up like this:

Id       IP address                                                                              Port      weight 

2        /opt/memcached/run/lords/memcached-1.sock            0             1

Server Information:

Hosting Package: default

cPanel Version: 78.0 (build 41)

Apache Version: 2.4.41

PHP Version: 7.2.23

MySQL Version: 10.2.28-MariaDB

Architecture: x86_64

Operating System: linux

Path to Sendmail: /usr/sbin/sendmail

Path to Perl: /usr/bin/perl

Perl Version: 5.16.3

Kernel Version: 2.6.32-042stab128.2

 

Prestashop server information: Linux #1 SMP Thu Mar 22 10:58:36 MSK 2018 x86_64

Server Software Version: Apache

PHP Version: 7.2.24

Limit memory: 4G

Maximum execution time: 300

Size Max. Files to upload: 256M

 

I will be mighty grateful to anyone that can help.

 

Screen Shot 2019-11-06 at 07.50.18.png

Screen Shot 2019-11-06 at 07.36.00.png

Link to comment
Share on other sites

  • 3 years later...

Hello @Mathew Nwaneri

I just needed the same thing as you, since when prestashop clears the cache from Advanced Parameters -> Performance, it clears the local smarty cache, but not the cache server, in this case "memcached".

So I made a small file called: flush_cache.php with the following code:

<?php
require dirname(__FILE__).'/config/config.inc.php';

$cache = Cache::getInstance();
$cache->flush();

die('Memcached cleared');

I put it in the root of the store via FTP and just call it from the browser URL (Example: https://mystore.com/flush_cache.php) and that's it. You can also place a CRON with this URL and the frequency of execution that you want and that's it.

I hope it can be of use to others.

Best regards.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...