UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'WtoX+SbJPEG7C35SNMs26z+c0v+raG7/NL911b93mzw=' 
WHERE 
  key_id = '4a246600594c90343605144f4fb519f64479e7765dd857cee86e6f2f57d6bf7c' 
  AND (
    token = 'WtoX+SbJPEG7C35SNMs26z+c0v+raG7/NL911b93mzw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00035