IncrementAccessCount 增加访问计数
(ctx context.Context, namespace, key string)
| 325 | |
| 326 | // IncrementAccessCount 增加访问计数 |
| 327 | func (s *PostgreSQLStore) IncrementAccessCount(ctx context.Context, namespace, key string) error { |
| 328 | if s.closed { |
| 329 | return ErrStoreClosed |
| 330 | } |
| 331 | |
| 332 | query := fmt.Sprintf(` |
| 333 | UPDATE %s |
| 334 | SET access_count = access_count + 1, last_accessed = $1, updated_at = $1 |
| 335 | WHERE namespace = $2 AND key = $3 |
| 336 | `, s.tableName) |
| 337 | |
| 338 | result, err := s.db.ExecContext(ctx, query, time.Now(), namespace, key) |
| 339 | if err != nil { |
| 340 | return NewStoreError("UPDATE_ERROR", "failed to increment access count", err) |
| 341 | } |
| 342 | |
| 343 | rowsAffected, _ := result.RowsAffected() |
| 344 | if rowsAffected == 0 { |
| 345 | return ErrMemoryNotFound |
| 346 | } |
| 347 | |
| 348 | return nil |
| 349 | } |
| 350 | |
| 351 | // GetStats 获取统计信息 |
| 352 | func (s *PostgreSQLStore) GetStats(ctx context.Context, namespace string) (*MemoryStats, error) { |
nothing calls this directly
no test coverage detected