xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
Commit a0ec540e7be1aa620a559c6f77537b9687aacc11

Improved user info caching
Author: Catalin(ux) M. BOIE
Author date (UTC): 2016-04-06 16:16
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2016-04-06 16:16
Parent(s): c2732004dbb1695444be3030111faf4401c83fb1
Signing key:
Tree: 7650410e6306ee5f5e5401100fae67a12598dd5b
File Lines added Lines deleted
inc/user.inc.php 16 23
File inc/user.inc.php changed (mode: 100644) (index 47aedee..ca4cbe7)
... ... function rg_user_cosmetic(&$row)
126 126 if (isset($row['itime'])) if (isset($row['itime']))
127 127 $row['itime_nice'] = gmdate('Y-m-d', $row['itime']); $row['itime_nice'] = gmdate('Y-m-d', $row['itime']);
128 128
129 $row['email_md5'] = md5(strtolower(trim($row['email'])));
130
131 $row['homepage'] = rg_re_userpage($row);
132
129 133 $row['HTML:gravatar'] = '<img class="gravatar" src="https://www.gravatar.com/avatar/' $row['HTML:gravatar'] = '<img class="gravatar" src="https://www.gravatar.com/avatar/'
130 134 . $row['email_md5'] . $row['email_md5']
131 135 . '?s=64&amp;r=g" alt="avatar" width="64" height="64" />'; . '?s=64&amp;r=g" alt="avatar" width="64" height="64" />';
 
... ... function rg_user_edit($db, $d)
522 526 $row = rg_sql_fetch_array($res); $row = rg_sql_fetch_array($res);
523 527 rg_sql_free_result($res); rg_sql_free_result($res);
524 528
525 // More stuff to be cached
526 $d['email_md5'] = md5(strtolower(trim($d['email'])));
527
528 529 if ($d['uid'] == 0) { // add if ($d['uid'] == 0) { // add
530 $d['uid'] = $row['uid'];
529 531 rg_cache_set('user' . '::' . $d['uid'] . '::' . ':info', rg_cache_set('user' . '::' . $d['uid'] . '::' . ':info',
530 532 $d, RG_SOCKET_NO_WAIT); $d, RG_SOCKET_NO_WAIT);
531 533
532 534 $event = array('category' => 2000, 'prio' => 50, $event = array('category' => 2000, 'prio' => 50,
533 'ui' => array(
534 'uid' => $row['uid'],
535 'realname' => $d['realname'],
536 'username' => $d['username'],
537 'email' => $d['confirmed'] > 0 ? $d['email'] : "",
538 'confirm_token' => $d['confirm_token']
539 ),
535 'ui' => $d,
540 536 'rg_account_email_confirm' => $rg_account_email_confirm, 'rg_account_email_confirm' => $rg_account_email_confirm,
541 537 'url' => rg_base_url() 'url' => rg_base_url()
542 538 ); );
 
... ... function rg_user_info($db, $uid, $user, $email)
630 626 "email" => $email); "email" => $email);
631 627
632 628 if ($uid > 0) { if ($uid > 0) {
633 // We will get all info about fthe user not only 'info'
629 // We will get all info about the user not only 'info'
634 630 // to populate the cache with all info. // to populate the cache with all info.
635 631 $c = rg_cache_get('user' . '::' . $uid); $c = rg_cache_get('user' . '::' . $uid);
636 if ($c !== FALSE) {
637 if (isset($c['info'])) {
638 $ret = $c['info'];
639 $ret['exists'] = 1;
640 rg_user_cosmetic($ret);
641 break;
642 }
632 if (($c !== FALSE)
633 && (isset($c['info']))
634 && (isset($c['info']['uid']))) {
635 $ret = $c['info'];
636 $ret['exists'] = 1;
637 rg_user_cosmetic($ret);
638 break;
643 639 } }
644 640
645 641 $sql = "SELECT * FROM users WHERE uid = @@uid@@"; $sql = "SELECT * FROM users WHERE uid = @@uid@@";
 
... ... function rg_user_info($db, $uid, $user, $email)
686 682
687 683 $ret = array_merge($ret, $row); $ret = array_merge($ret, $row);
688 684
689 $ret['homepage'] = rg_re_userpage($ret);
690 $ret['email_md5'] = md5(strtolower(trim($ret['email'])));
691
692 685 rg_cache_set('user' . '::' . $ret['uid'] . '::' . 'info', rg_cache_set('user' . '::' . $ret['uid'] . '::' . 'info',
693 686 $ret, RG_SOCKET_NO_WAIT); $ret, RG_SOCKET_NO_WAIT);
694 687 rg_cache_set('username_to_uid::' . $ret['username'], rg_cache_set('username_to_uid::' . $ret['username'],
 
... ... function rg_user_confirm($db, $token)
1422 1415 } }
1423 1416 rg_sql_free_result($res); rg_sql_free_result($res);
1424 1417
1425 rg_cache_merge('user' . '::' . $uid . '::' . 'info',
1426 $params, RG_SOCKET_NO_WAIT);
1418 rg_cache_set('user' . '::' . $uid . '::' . 'info'
1419 . '::' . 'confirmed', $now, RG_SOCKET_NO_WAIT);
1427 1420
1428 1421 $ret = $uid; $ret = $uid;
1429 1422 break; break;
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master