IncrementAccessCount 增加访问计数
(ctx context.Context, namespace, key string)
| 314 | |
| 315 | // IncrementAccessCount 增加访问计数 |
| 316 | func (s *MySQLStore) IncrementAccessCount(ctx context.Context, namespace, key string) error { |
| 317 | if s.closed { |
| 318 | return ErrStoreClosed |
| 319 | } |
| 320 | |
| 321 | query := fmt.Sprintf(` |
| 322 | UPDATE %s |
| 323 | SET access_count = access_count + 1, last_accessed = ?, updated_at = ? |
| 324 | WHERE namespace = ? AND `+"`key`"+` = ? |
| 325 | `, s.tableName) |
| 326 | |
| 327 | now := time.Now() |
| 328 | result, err := s.db.ExecContext(ctx, query, now, now, namespace, key) |
| 329 | if err != nil { |
| 330 | return NewStoreError("UPDATE_ERROR", "failed to increment access count", err) |
| 331 | } |
| 332 | |
| 333 | rowsAffected, _ := result.RowsAffected() |
| 334 | if rowsAffected == 0 { |
| 335 | return ErrMemoryNotFound |
| 336 | } |
| 337 | |
| 338 | return nil |
| 339 | } |
| 340 | |
| 341 | // GetStats 获取统计信息 |
| 342 | func (s *MySQLStore) GetStats(ctx context.Context, namespace string) (*MemoryStats, error) { |
nothing calls this directly
no test coverage detected