当前位置:首页>python>Python AI Agent 零基础教程 | 第7篇:记忆系统——让AI Agent记住上下文

Python AI Agent 零基础教程 | 第7篇:记忆系统——让AI Agent记住上下文

  • 2026-07-02 12:57:04
Python AI Agent 零基础教程 | 第7篇:记忆系统——让AI Agent记住上下文
   

Python AI Agent 零基础教程 | 第7篇:记忆系统——让AI Agent记住上下文


前言

你有没有遇到过这种情况:和 AI 聊了半天后,第二天再问它,它完全不记得你们之前聊过什么? 这就是因为 AI 缺少"记忆系统"!今天我们就来学习如何给 AI Agent 装上"记忆",让它能够记住上下文,甚至长期学习。


一、为什么 AI Agent 需要记忆?
1.1 对比:传统 AI vs 有记忆的 AI
对比项传统 AI有记忆的 AI Agent
记住之前说的❌ 每次都是新对话✅ 可以记住历史
了解用户偏好❌ 不了解✅ 可以记住用户习惯
持续学习❌ 不学习✅ 可以积累知识
对话连贯性❌ 可能前后矛盾✅ 保持一致
1.2 记忆的类型
Python 代码
┌─────────────────────────────────────────────────────────────┐
│                    AI Agent 记忆系统                        │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  ┌─────────────────────────────────────────────────────┐   │
│  │                    长期记忆                          │   │
│  │  ┌─────────┐  ┌─────────┐  ┌─────────┐            │   │
│  │  │ 知识库  │  │用户画像 │  │ 经验库  │            │   │
│  │  └─────────┘  └─────────┘  └─────────┘            │   │
│  └─────────────────────────────────────────────────────┘   │
│                           ▲                                 │
│                           │                                 │
│  ┌─────────────────────────────────────────────────────┐   │
│  │                    短期记忆                          │   │
│  │  ┌─────────────────────────────────────────────┐   │   │
│  │  │              对话历史(上下文)               │   │   │
│  │  └─────────────────────────────────────────────┘   │   │
│  └─────────────────────────────────────────────────────┘   │
│                                                             │
└─────────────────────────────────────────────────────────────┘
1.3 记忆系统的作用

-上下文理解:理解"它"指代什么

 -个性化服务:记住用户偏好,提供更好的服务

 -知识积累:从交互中学习,不断进步

 -连续对话:实现真正的多轮对话


二、短期记忆:对话历史管理
2.1 最简单的记忆实现
Python 代码
class SimpleMemoryAgent:
    """带简单记忆的 Agent"""
    
    def __init__(self, api_key):
        self.api_key = api_key
        self.messages = []  # 对话历史就是记忆
    
    def set_system_prompt(self, prompt):
        """设置系统提示词"""
        self.messages = [{"role": "system", "content": prompt}]
    
    def think(self, user_input):
        """带记忆的思考"""
        
        # 1. 添加用户消息到记忆
        self.messages.append({"role": "user", "content": user_input})
        
        # 2. 调用 API
        response = self._call_api()
        
        # 3. 添加 AI 回复到记忆
        ai_message = response["choices"][0]["message"]
        self.messages.append(ai_message)
        
        return ai_message["content"]
    
    def _call_api(self):
        # API 调用...
        pass
    
    def show_memory(self):
        """查看记忆内容"""
        print("\n📝 当前记忆:")
        for msg in self.messages:
            role = msg["role"]
            content = msg["content"][:50] + "..." if len(msg["content"]) > 50 else msg["content"]
            print(f"  {role}: {content}")
2.2 记忆容量管理

AI 有上下文长度限制(通常是 4K-128K tokens),当对话太长时需要管理记忆。

Python 代码
class ManagedMemoryAgent:
    """带记忆管理的 Agent"""
    
    def __init__(self, api_key, max_tokens=3000):
        self.api_key = api_key
        self.max_tokens = max_tokens
        self.messages = []
    
    def think(self, user_input):
        """思考(自动管理记忆)"""
        
        # 添加用户消息
        self.messages.append({"role": "user", "content": user_input})
        
        # 检查是否需要压缩记忆
        if self._estimate_tokens() > self.max_tokens:
            self._compress_memory()
        
        # 调用 API
        response = self._call_api()
        
        # 添加 AI 回复
        ai_message = response["choices"][0]["message"]
        self.messages.append(ai_message)
        
        return ai_message["content"]
    
    def _estimate_tokens(self):
        """估算当前 tokens 数量"""
        total = 0
        for msg in self.messages:
            # 粗略估算:中文约 2 tokens/字
            total += len(msg["content"]) * 1.3
        return int(total)
    
    def _compress_memory(self):
        """压缩记忆(保留重要信息)"""
        
        # 策略:保留 system 消息 + 最近 10 条对话
        if len(self.messages) > 11:
            system_msg = self.messages[0] if self.messages[0]["role"] == "system" else None
            recent_msgs = self.messages[-10:]
            
            if system_msg:
                self.messages = [system_msg] + recent_msgs
            else:
                self.messages = recent_msgs
        
        print(f"📦 记忆已压缩,当前 {len(self.messages)} 条消息")
2.3 智能记忆管理
Python 代码
class SmartMemoryAgent:
    """智能记忆管理 Agent"""
    
    def __init__(self, api_key):
        self.api_key = api_key
        self.messages = []
        self.important_info = []  # 重要信息单独存储
    
    def think(self, user_input):
        """思考(提取重要信息)"""
        
        self.messages.append({"role": "user", "content": user_input})
        
        response = self._call_api()
        ai_message = response["choices"][0]["message"]
        self.messages.append(ai_message)
        
        # 尝试提取重要信息
        self._extract_important_info(user_input, ai_message["content"])
        
        return ai_message["content"]
    
    def _extract_important_info(self, user_input, ai_response):
        """从对话中提取重要信息"""
        
        # 这里可以用关键词检测来识别重要信息
        important_keywords = ["名字", "生日", "喜好", "地址", "电话", "邮箱"]
        
        for keyword in important_keywords:
            if keyword in user_input or keyword in ai_response:
                # 提取包含关键词的句子
                if keyword in user_input:
                    self.important_info.append(f"用户提到:{keyword}")
                    print(f"💡 记住重要信息:{keyword}")
    
    def get_user_profile(self):
        """获取用户画像"""
        return {
            "important_info": self.important_info,
            "conversation_count": len(self.messages) // 2
        }

三、长期记忆:用户画像
3.1 用户画像结构
Python 代码
class UserProfile:
    """用户画像"""
    
    def __init__(self, user_id):
        self.user_id = user_id
        self.name = None
        self.preferences = {}  # 偏好
        self.history = []       # 历史交互
        self.knowledge = {}     # 已知知识
    
    def update(self, key, value):
        """更新用户信息"""
        if key in ["name", "age", "city"]:
            setattr(self, key, value)
        else:
            self.preferences[key] = value
        
        print(f"✅ 已更新用户画像:{key} = {value}")
    
    def get_summary(self):
        """获取用户摘要"""
        return f"""
用户ID:{self.user_id}
姓名:{self.name or "未知"}
偏好:{self.preferences}
"""
    
    def to_dict(self):
        """转换为字典"""
        return {
            "user_id": self.user_id,
            "name": self.name,
            "preferences": self.preferences,
            "history": self.history,
            "knowledge": self.knowledge
        }
    
    @classmethod
    def from_dict(cls, data):
        """从字典创建"""
        profile = cls(data["user_id"])
        profile.name = data.get("name")
        profile.preferences = data.get("preferences", {})
        profile.history = data.get("history", [])
        profile.knowledge = data.get("knowledge", {})
        return profile
3.2 带用户画像的 Agent
Python 代码
class PersonalizedAgent:
    """个性化 Agent"""
    
    def __init__(self, api_key, user_id):
        self.api_key = api_key
        self.messages = []
        self.user_profile = UserProfile(user_id)
    
    def set_system_prompt(self):
        """根据用户画像设置系统提示词"""
        
        base_prompt = """你是一个智能助手,能够记住用户信息并提供个性化服务。"""
        
        # 如果有用户信息,添加到系统提示词
        if self.user_profile.name:
            base_prompt += f"\n当前用户名叫 {self.user_profile.name}。"
        
        if self.user_profile.preferences:
            prefs = ", ".join([f"{k}={v}" for k, v in self.user_profile.preferences.items()])
            base_prompt += f"\n用户偏好:{prefs}"
        
        self.messages = [{"role": "system", "content": base_prompt}]
    
    def think(self, user_input):
        """思考"""
        
        # 更新用户画像
        self._update_profile_from_input(user_input)
        
        # 正常对话流程
        self.messages.append({"role": "user", "content": user_input})
        
        response = self._call_api()
        ai_message = response["choices"][0]["message"]
        self.messages.append(ai_message)
        
        return ai_message["content"]
    
    def _update_profile_from_input(self, user_input):
        """从输入中更新用户画像"""
        
        # 简单的关键词检测
        if "我叫" in user_input:
            name = user_input.split("我叫")[1].split()[0]
            self.user_profile.update("name", name)
        
        if "我喜欢" in user_input:
            like = user_input.split("我喜欢")[1].split()[0]
            self.user_profile.update("hobby", like)
    
    def save_profile(self, filename):
        """保存用户画像"""
        import json
        with open(filename, "w", encoding="utf-8") as f:
            json.dump(self.user_profile.to_dict(), f, ensure_ascii=False, indent=2)
        print(f"✅ 用户画像已保存到 {filename}")
    
    def load_profile(self, filename):
        """加载用户画像"""
        import json
        with open(filename, "r", encoding="utf-8") as f:
            data = json.load(f)
            self.user_profile = UserProfile.from_dict(data)
        print(f"✅ 用户画像已加载")

四、持久化存储
4.1 文件存储
Python 代码
import json
from datetime import datetime

class PersistentAgent:
    """持久化 Agent"""
    
    def __init__(self, api_key, user_id):
        self.api_key = api_key
        self.user_id = user_id
        self.conversation_file = f"conversation_{user_id}.json"
        self.profile_file = f"profile_{user_id}.json"
        
        # 加载已有数据
        self.messages = self._load_conversation()
        self.user_profile = self._load_profile()
    
    def think(self, user_input):
        """思考并自动保存"""
        
        self.messages.append({"role": "user", "content": user_input})
        
        response = self._call_api()
        ai_message = response["choices"][0]["message"]
        self.messages.append(ai_message)
        
        # 自动保存
        self._save_conversation()
        
        return ai_message["content"]
    
    def _load_conversation(self):
        """加载对话历史"""
        try:
            with open(self.conversation_file, "r", encoding="utf-8") as f:
                return json.load(f)
        except FileNotFoundError:
            return []
    
    def _save_conversation(self):
        """保存对话历史"""
        with open(self.conversation_file, "w", encoding="utf-8") as f:
            json.dump(self.messages, f, ensure_ascii=False, indent=2)
    
    def _load_profile(self):
        """加载用户画像"""
        try:
            with open(self.profile_file, "r", encoding="utf-8") as f:
                return UserProfile.from_dict(json.load(f))
        except FileNotFoundError:
            return UserProfile(self.user_id)
    
    def _save_profile(self):
        """保存用户画像"""
        with open(self.profile_file, "w", encoding="utf-8") as f:
            json.dump(self.user_profile.to_dict(), f, ensure_ascii=False, indent=2)
4.2 SQLite 数据库存储
Python 代码
import sqlite3
from datetime import datetime

class DatabaseAgent:
    """使用数据库的 Agent"""
    
    def __init__(self, api_key, db_name="agent_memory.db"):
        self.api_key = api_key
        self.conn = sqlite3.connect(db_name)
        self._init_database()
    
    def _init_database(self):
        """初始化数据库"""
        cursor = self.conn.cursor()
        
        # 创建对话表
        cursor.execute("""
            CREATE TABLE IF NOT EXISTS conversations (
                id INTEGER PRIMARY KEY AUTOINCREMENT,
                user_id TEXT,
                role TEXT,
                content TEXT,
                created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
            )
        """)
        
        # 创建用户画像表
        cursor.execute("""
            CREATE TABLE IF NOT EXISTS user_profiles (
                user_id TEXT PRIMARY KEY,
                name TEXT,
                preferences TEXT,
                updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
            )
        """)
        
        self.conn.commit()
    
    def save_message(self, user_id, role, content):
        """保存消息"""
        cursor = self.conn.cursor()
        cursor.execute(
            "INSERT INTO conversations (user_id, role, content) VALUES (?, ?, ?)",
            (user_id, role, content)
        )
        self.conn.commit()
    
    def get_conversation_history(self, user_id, limit=20):
        """获取对话历史"""
        cursor = self.conn.cursor()
        cursor.execute(
            "SELECT role, content FROM conversations WHERE user_id = ? ORDER BY id DESC LIMIT ?",
            (user_id, limit)
        )
        results = cursor.fetchall()
        return [{"role": r[0], "content": r[1]} for r in reversed(results)]
    
    def save_profile(self, user_id, name, preferences):
        """保存用户画像"""
        cursor = self.conn.cursor()
        cursor.execute("""
            INSERT OR REPLACE INTO user_profiles (user_id, name, preferences, updated_at)
            VALUES (?, ?, ?, ?)
        """, (user_id, name, json.dumps(preferences), datetime.now()))
        self.conn.commit()
    
    def close(self):
        """关闭数据库连接"""
        self.conn.close()

五、完整记忆系统实现
5.1 综合记忆 Agent
Python 代码
class FullMemoryAgent:
    """完整记忆系统 Agent"""
    
    def __init__(self, api_key, user_id="default"):
        self.api_key = api_key
        self.user_id = user_id
        
        # 短期记忆
        self.short_term_memory = []
        
        # 长期记忆
        self.long_term_memory = {
            "user_profile": {},
            "knowledge_base": {},
            "conversation_summary": ""
        }
        
        # 配置
        self.max_short_term = 20  # 最多保留20条对话
    
    def set_system_prompt(self, base_prompt):
        """设置系统提示词"""
        
        # 构建完整的系统提示词
        full_prompt = base_prompt + "\n\n"
        
        # 添加用户画像
        if self.long_term_memory["user_profile"]:
            profile = self.long_term_memory["user_profile"]
            full_prompt += f"用户信息:{json.dumps(profile, ensure_ascii=False)}\n"
        
        # 添加对话摘要
        if self.long_term_memory["conversation_summary"]:
            full_prompt += f"对话摘要:{self.long_term_memory['conversation_summary']}\n"
        
        self.system_prompt = full_prompt
        self.short_term_memory = [{"role": "system", "content": full_prompt}]
    
    def think(self, user_input):
        """思考"""
        
        # 1. 添加到短期记忆
        self.short_term_memory.append({
            "role": "user",
            "content": user_input
        })
        
        # 2. 检查记忆容量
        if len(self.short_term_memory) > self.max_short_term:
            self._summarize_and_compress()
        
        # 3. 调用 API
        response = self._call_api()
        ai_message = response["choices"][0]["message"]
        
        # 4. 添加回复到短期记忆
        self.short_term_memory.append(ai_message)
        
        # 5. 提取重要信息到长期记忆
        self._extract_to_long_term(user_input, ai_message["content"])
        
        return ai_message["content"]
    
    def _call_api(self):
        # API 调用...
        pass
    
    def _summarize_and_compress(self):
        """总结并压缩记忆"""
        
        # 保留系统提示词 + 最近的对话
        system_msg = self.short_term_memory[0]
        recent_msgs = self.short_term_memory[-10:]
        
        # 更新短期记忆
        self.short_term_memory = [system_msg] + recent_msgs
        
        # 更新对话摘要
        self.long_term_memory["conversation_summary"] = "最近的对话涉及..."
        
        print("📦 记忆已压缩")
    
    def _extract_to_long_term(self, user_input, ai_response):
        """提取信息到长期记忆"""
        
        # 提取用户信息
        if "我叫" in user_input:
            name = user_input.split("我叫")[1].split()[0]
            self.long_term_memory["user_profile"]["name"] = name
        
        # 提取偏好
        if "喜欢" in user_input:
            self.long_term_memory["user_profile"]["preference"] = user_input
    
    def show_memory(self):
        """显示记忆状态"""
        print("\n" + "="*50)
        print("🧠 记忆状态")
        print("="*50)
        print(f"短期记忆:{len(self.short_term_memory)} 条")
        print(f"长期记忆:{json.dumps(self.long_term_memory, ensure_ascii=False, indent=2)}")
        print("="*50)

六、实战:记忆助手
6.1 完整代码
Python 代码
import requests
import json

class MemoryAssistant:
    """有记忆的个人助手"""
    
    def __init__(self, api_key, user_name="用户"):
        self.api_key = api_key
        self.user_name = user_name
        self.short_term = []  # 短期记忆
        self.long_term = {
            "name": user_name,
            "preferences": {},
            "todos": [],
            "facts": []
        }
        
        # 系统提示词
        self.system_prompt = f"""你是一个智能个人助手,名字叫小智。

你需要:
  1. 记住用户的名字和个人信息
  2. 记住用户的偏好和习惯
  3. 保持对话的连贯性
  4. 主动询问用户需求
当前用户:{user_name}""" self.short_term.append({"role": "system", "content": self.system_prompt}) def think(self, user_input): """思考并回复""" # 记录用户消息 self.short_term.append({"role": "user", "content": user_input}) # 提取信息到长期记忆 self._learn_from_input(user_input) # 调用 API response = self._call_api() ai_message = response["choices"][0]["message"] # 记录 AI 回复 self.short_term.append(ai_message) # 管理记忆容量 if len(self.short_term) > 20: self._compress_memory() return ai_message["content"] def _learn_from_input(self, user_input): """从输入中学习""" # 记住名字 if "我叫" in user_input or "我是" in user_input: for keyword in ["我叫", "我是"]: if keyword in user_input: parts = user_input.split(keyword) if len(parts) > 1: name = parts[1].split()[0].strip(",。") self.long_term["name"] = name self.long_term["facts"].append(f"用户名叫{name}") break # 记住偏好 if "我喜欢" in user_input: like = user_input.split("我喜欢")[1].split()[0] self.long_term["preferences"]["喜欢"] = like if "我不喜欢" in user_input: dislike = user_input.split("我不喜欢")[1].split()[0] self.long_term["preferences"]["不喜欢"] = dislike def _compress_memory(self): """压缩记忆""" # 保留系统消息 + 最近对话 self.short_term = [self.short_term[0]] + self.short_term[-12:] print("📝 记忆已优化") def _call_api(self): url = "https://api.openai.com/v1/chat/completions" headers = { "Content-Type": "application/json", "Authorization": f"Bearer {self.api_key}" } data = { "model": "gpt-3.5-turbo", "messages": self.short_term } response = requests.post(url, headers=headers, json=data) return response.json() def show_knowledge(self): """展示已学到的知识""" print("\n📚 我记住的关于你的信息:") print(f" 名字:{self.long_term.get('name', '未知')}") if self.long_term.get("preferences"): print(f" 偏好:{self.long_term['preferences']}") if self.long_term.get("facts"): print(f" 事实:{self.long_term['facts']}") def run(self): """运行交互式对话""" print("="*50) print("🧠 记忆助手已启动!") print("输入 'quit' 退出,'memory' 查看记忆") print("="*50) while True: try: user_input = input("\n👤 你:").strip() if not user_input: continue if user_input.lower() == "quit": print("再见!") break elif user_input.lower() == "memory": self.show_knowledge() else: response = self.think(user_input) print(f"\n🤖 小智:{response}") except KeyboardInterrupt: print("\n再见!") break 使用 if __name__ == "__main__": assistant = MemoryAssistant("sk-xxxxxx", "小明") assistant.run()
6.2 运行效果
Python 代码
==================================================
🧠 记忆助手已启动!
输入 'quit' 退出,'memory' 查看记忆
==================================================

👤 你:我叫张三,25岁,在北京工作

🤖 小智:你好张三!很高兴认识你。我是你的智能助手小智,有什么我可以帮你的吗?

👤 你:我喜欢编程,不喜欢加班

📝 记忆已优化

🤖 小智:明白了!你喜欢编程,不喜欢加班。作为程序员,我们都希望能更好地平衡工作和生活。

👤 你:memory
📚 我记住的关于你的信息:
  名字:张三
  偏好:{'喜欢': '编程', '不喜欢': '加班'}
  事实:['用户名叫张三']

👤 你:明天下午3点提醒我开会

🤖 小智:好的张三,我已经记住了!明天下午3点我会提醒你开会。还有什么需要我帮忙的吗?

👤 你:你还记得我叫什么吗?

🤖 小智:当然记得,你叫张三,今年25岁,在北京工作。喜欢编程,不喜欢加班。有什么需要我帮忙的吗?

七、本章小结

今天我们学习了:

记忆类型实现方式
✅ 短期记忆对话历史列表
✅ 记忆管理Token 限制 + 压缩
✅ 长期记忆用户画像 + 知识库
✅ 持久化文件存储 + 数据库
✅ 智能学习自动提取重要信息

---

下期预告
第8篇:工具调用——扩展 AI Agent 的能力

下一期我们将学习:

 - 什么是工具调

 - 内置工具设计

 - 动态工具注册

 - 实战:天气查询 Agent


👨‍💻 作者:鹏鹏 | 专注于 AI + 编程教育
 📱 关注公众号「跟着鹏鹏学技术」
 💬 动手练习:给你的 Agent 添加记忆功能!

往期精选

- 📖 [第5篇:构建第一个AI Agent]() - 📖 [第6篇:提示词工程]() 


   

👨‍💻 作者:鹏鹏

   

📱 关注公众号「跟着鹏鹏学技术」

   

🔔 点赞 + 在看,让更多人看到!

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-04 13:56:06 HTTP/2.0 GET : https://f.mffb.com.cn/a/488860.html
  2. 运行时间 : 0.092547s [ 吞吐率:10.81req/s ] 内存消耗:4,632.66kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=08c0dd61295518282ec5d14b7d5204dc
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000614s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000645s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000288s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000334s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000645s ]
  6. SELECT * FROM `set` [ RunTime:0.000200s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000571s ]
  8. SELECT * FROM `article` WHERE `id` = 488860 LIMIT 1 [ RunTime:0.000492s ]
  9. UPDATE `article` SET `lasttime` = 1783144566 WHERE `id` = 488860 [ RunTime:0.001200s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000265s ]
  11. SELECT * FROM `article` WHERE `id` < 488860 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000510s ]
  12. SELECT * FROM `article` WHERE `id` > 488860 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000380s ]
  13. SELECT * FROM `article` WHERE `id` < 488860 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.017510s ]
  14. SELECT * FROM `article` WHERE `id` < 488860 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.001004s ]
  15. SELECT * FROM `article` WHERE `id` < 488860 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.000799s ]
0.094130s