Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Memcached Caching Function
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / M-BiTsy / M-BiTsy Support

2021-01-29 05:42:08
I wrote this to aid our own database issues with our community, and most of it is caused by our heavy use of persistant AJAX calls, hammering the server to often high loads on local processes (like php-FPM), so I wrote a function without ever googling, and so far so good.

maybe this will help or at least provide some testing grounds.

[CODE=php]
function cached_query(string $query, string $fetchtype) : array
{
global $db;
$memtest = new Memcached();
$memtest->addServer('127.0.0.1', 11211);
$retval = $db->query_params($query);
$result = $retval->$fetchtype();
$querykey = 'KEY' . md5($query);
$memtest->set($querykey, $result);
return $memtest->get($querykey);

}
[/CODE]

Test:

[CODE=php]
cached_query('SELECT avatar, username, id FROM users WHERE user_id IN (1)', 'fetchAll');
[/CODE]

I am still working on return cases on the function, so we can call the function and return true or false, and also allow to read array keys from the get() in the function, not sure how to do that except pushing the array to the function param? maybe some advise on this. anyway try it out!
2021-02-11 17:43:14
This is terrible and is also outdated as of current. Β This caches too much and must contain handling for newly uploaded torrents (clear cache), etc.

It's much faster but leaves your content behind for a bit. Use with caution.Β 
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728