UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'gNRZZ8dRNqLu6J7O0cig0WZeWNn5gQKP7fb+BRZfLZk=' 
WHERE 
  key_id = '8f406e9d829700fdc7525e8754ee97b10f3c84d1ab668622b6694e5338707ecc' 
  AND (
    token = 'gNRZZ8dRNqLu6J7O0cig0WZeWNn5gQKP7fb+BRZfLZk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00025