UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'TgM3BTUMVERwxWYMggOEvwVyKkHZILW9OyYvntjlUYY=' 
WHERE 
  key_id = '40416f5c3fb277b5167790b4267db42cb873eb50b97f0b48f8247f520dc621d0' 
  AND (
    token = 'TgM3BTUMVERwxWYMggOEvwVyKkHZILW9OyYvntjlUYY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00029