UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'bd0O7cEOv9CYZIGERbFBfhsoSCuatm7mPekfYMD+37Q=' 
WHERE 
  key_id = '627207ed1768bc4031e56929336a35ca703131801ffe8891a52576307306110b' 
  AND (
    token = 'bd0O7cEOv9CYZIGERbFBfhsoSCuatm7mPekfYMD+37Q=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032