UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'if5HVA503uW3M2gOKQzNdfZbHBRLP9GTyq9j3kaoXHs=' 
WHERE 
  key_id = '622c68754e4aa0fb283770c5b02b666dd088cd1f638038a67a7c7c487d425478' 
  AND (
    token = 'if5HVA503uW3M2gOKQzNdfZbHBRLP9GTyq9j3kaoXHs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00016