Skip to content

Instantly share code, notes, and snippets.

@MilesChou
MilesChou / README.md
Last active May 23, 2026 07:22
Reproducer for Laravel PhpRedisConnection reconnect-without-retry inconsistency

Laravel Redis "reconnect-without-retry" reproducer

This reproducer demonstrates an inconsistency in Laravel's framework code:

  • Illuminate\Database\Connection reconnects and retries on lost connection — caller sees a transparent recovery.
  • Illuminate\Redis\Connections\PhpRedisConnection reconnects on lost connection but immediately throws — the rebuilt \Redis client is wasted, the caller still sees an exception.

It also shows that phpredis' built-in OPT_MAX_RETRIES / backoff options (integrated into Laravel via #54191) don't help here. Those options retry connection-loss detected before sending a command (via redis_check_eof); they don't engage on the "command already sent, read timed out" path that this reproducer simulates.

What this reproducer does

<?php
// See https://github.com/web-token/jwt-framework/tree/v1.3.9 for about JWT
function createAppleIDSecret()
{
$privateKey = file_get_contents('/path/to/your/key');
$keyId = 'key_id';
$teamId = 'team_id';
$clientId = 'client_id';
@MilesChou
MilesChou / .dockerignore
Last active March 20, 2019 03:36
The basic Dockerfile for Laravel Framework
# Docker files
.dockerignore
Dockerfile
# Git files
.git
# Node files
node_modules
<?php
$totalScore = 0;
foreach ($exam as $value) {
foreach ($value->mocks as $mock) {
foreach ($mock->items as $item) {
$totalScore += (int)$item->ext->score;
}
}
@MilesChou
MilesChou / adapter.php
Last active January 29, 2021 14:31
Adapter function example for mysql to mysqli
<?php
if (!function_exists('mysql_connect')) {
function mysql_connect($host, $username, $password) {
mysqli_connect($host, $username, $password);
}
}
mysql_connect('127.0.0.1', 'root', 'password');
@MilesChou
MilesChou / greeting.php
Last active December 2, 2016 05:19
greeting
<?php
class Client
{
public $greetingRules = [];
public function __construct()
{
$this->greetingRules[] = new MorningGreeting();
$this->greetingRules[] = new AfternoonGreeting();

Code review

程式碼審查

類型

  • Pair Programming (直接的做法 - 時間短 - feedback 慢 - 高密度)
  • 可使用在新人加入時
@MilesChou
MilesChou / Makefile
Last active May 25, 2019 10:34
Dockerfile 懶人用
#!/usr/bin/make -f
IMAGE := $(shell basename $(shell pwd))
VERSION := latest
.PHONY: all build rebuild shell run
# ------------------------------------------------------------------------------
all: build
@MilesChou
MilesChou / TestFragment.java
Created April 2, 2014 07:46
摩天輪動畫
// ignore import
public class TestFragment extends Fragment
{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return inflater.inflate(R.layout.fragment, container, false);
}
<?php
/**
* class 教學
*
* class 全域需注意的重點:
* 1.全域:跟function一樣,一經宣告後,任何地方皆可使用。
* 2.不可重載:跟function一樣,一經宣告後,不可再宣告同名的class
*
* 建立class的重點: