UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'uW27yHf2TiOxf20+qXDeJSKA6acmW6e531PAHk9Gses=' 
WHERE 
  key_id = 'cd49b15ae0d0ed25cb8bfa02f3b4305ce1e2d2538e14764aa86b7303e4eb617a' 
  AND (
    token = 'uW27yHf2TiOxf20+qXDeJSKA6acmW6e531PAHk9Gses=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032