UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Y8DMaDPBmMwQMhUYUDYC4YFbq0UHVn3oiaAsUt7+VYc=' 
WHERE 
  key_id = '48ab8ece2e886805cafa2f05c82b6cacf3290e3a79d595d6987da9c6f2411bad' 
  AND (
    token = 'Y8DMaDPBmMwQMhUYUDYC4YFbq0UHVn3oiaAsUt7+VYc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00063