MCPcopy Create free account
hub / github.com/astercloud/aster / IncrementAccessCount

Method IncrementAccessCount

pkg/memory/logic/store_postgres.go:327–349  ·  view source on GitHub ↗

IncrementAccessCount 增加访问计数

(ctx context.Context, namespace, key string)

Source from the content-addressed store, hash-verified

325
326// IncrementAccessCount 增加访问计数
327func (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 获取统计信息
352func (s *PostgreSQLStore) GetStats(ctx context.Context, namespace string) (*MemoryStats, error) {

Callers

nothing calls this directly

Calls 1

NewStoreErrorFunction · 0.85

Tested by

no test coverage detected