Add caching layer and database helper
- Add CacheHelper for file-based caching with TTL support - Add Database helper for centralized connection management - Update WorkflowModel to cache status transitions (10 min TTL) - Update UserPreferencesModel to cache user prefs (5 min TTL) - Update manage_workflows.php to clear cache on changes - Update get_users.php to use Database helper (example migration) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ ini_set('display_errors', 0);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require_once dirname(__DIR__) . '/middleware/RateLimitMiddleware.php';
|
||||
require_once dirname(__DIR__) . '/models/WorkflowModel.php';
|
||||
RateLimitMiddleware::apply('api');
|
||||
|
||||
try {
|
||||
@@ -91,6 +92,7 @@ try {
|
||||
);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
WorkflowModel::clearCache(); // Clear workflow cache
|
||||
echo json_encode(['success' => true, 'transition_id' => $conn->insert_id]);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'error' => $stmt->error]);
|
||||
@@ -118,7 +120,11 @@ try {
|
||||
$id
|
||||
);
|
||||
|
||||
echo json_encode(['success' => $stmt->execute()]);
|
||||
$success = $stmt->execute();
|
||||
if ($success) {
|
||||
WorkflowModel::clearCache(); // Clear workflow cache
|
||||
}
|
||||
echo json_encode(['success' => $success]);
|
||||
$stmt->close();
|
||||
break;
|
||||
|
||||
@@ -130,7 +136,11 @@ try {
|
||||
|
||||
$stmt = $conn->prepare("DELETE FROM status_transitions WHERE transition_id = ?");
|
||||
$stmt->bind_param('i', $id);
|
||||
echo json_encode(['success' => $stmt->execute()]);
|
||||
$success = $stmt->execute();
|
||||
if ($success) {
|
||||
WorkflowModel::clearCache(); // Clear workflow cache
|
||||
}
|
||||
echo json_encode(['success' => $success]);
|
||||
$stmt->close();
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user