UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'miK8SJeN9OjVBtxN+e9cY02z8gihMvfQFZ4DwyAsX8E=' 
WHERE 
  key_id = '47c17c9ee903e3167db5994f3631206e6292bfb10859c2347beb81fd9152d88b' 
  AND (
    token = 'miK8SJeN9OjVBtxN+e9cY02z8gihMvfQFZ4DwyAsX8E=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024