UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'KLlSzaGC8OKC8Uo6ChpwZg22tWJJOTIJTJ5xGOwvZr8=' 
WHERE 
  key_id = '1a19cf5e9f716f870d28350b220eeadebade6c27e7be6d374366c8de3e160010' 
  AND (
    token = 'KLlSzaGC8OKC8Uo6ChpwZg22tWJJOTIJTJ5xGOwvZr8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00052