UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '3tYufav6leeyi3m2y+jfTxfOWgazpQgT2tPevAamL0w=' 
WHERE 
  key_id = 'a971fd89125ad769087d9fcbd77f66c55ff16df3461f43e0e1b7ad9c2d335739' 
  AND (
    token = '3tYufav6leeyi3m2y+jfTxfOWgazpQgT2tPevAamL0w=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00028